Ask Your Question
0

Convert file from docx to odt with LibreOffice

asked 2021-01-15 15:03:59 +0200

JynxMazre gravatar image

updated 2021-01-15 15:04:52 +0200

I have docx file that when I convert it to odt with LibreOffice by CLI it not opened with Microsoft Office (but opened by LibreOffice). my Command:

libreoffice --headless --convert-to odt sample.docx

When I save it with LibreOffice GUI to odt it open in both (Opened in Microsoft Office and LibreOffice)
I'm very confused and I do not know what is the reason for this file corruption.

My docx file : Link
My odt converted file with LibreOffice CLI that is corrupt: Link

edit retag flag offensive close merge delete

Comments

How do you mean that it is corrupted? Recent versions of MS Office can open .odt files. So, if the default application to open .odt files is set to MS Word, then Word will open it. That's not corruption, that's how your operating system works. It's odd if Windows starts both programs with your file, that's another matter. Please give more information.

floris v gravatar imagefloris v ( 2021-01-15 15:09:17 +0200 )edit

please download odt file that is converted from docx with above commad, then open it with libreoffice and microsoft office. you can see ms-office cannot open it and say this file is corrupt. or: download docx file in my question and convert it with above command to odt. then open it with ms office and say again this file is corrupt.

JynxMazre gravatar imageJynxMazre ( 2021-01-15 15:15:11 +0200 )edit

then open it with libreoffice and microsoft office

Don't assume users of LibreOffice do have MS Office as well.

Opaque gravatar imageOpaque ( 2021-01-15 15:26:32 +0200 )edit

@Opaque i want to upload it for another person and he has only ms office.

JynxMazre gravatar imageJynxMazre ( 2021-01-15 15:27:40 +0200 )edit

@floris v can you test it?

JynxMazre gravatar imageJynxMazre ( 2021-01-15 15:28:37 +0200 )edit

I don't have MS Office. But LibreOffice can save files in .docx format, so what's the problem?

floris v gravatar imagefloris v ( 2021-01-15 15:49:18 +0200 )edit

The .odt loads just fine, no corruption reported. Lorem Ipsum sample, repeated a few times. What's wrong with it on your side?

floris v gravatar imagefloris v ( 2021-01-15 15:53:47 +0200 )edit

@floris v Thanks. Yes LibreOffice open it correctly. but Ms Office not. I do not know if there is a problem with my conversion or a bug

JynxMazre gravatar imageJynxMazre ( 2021-01-15 16:17:03 +0200 )edit

I finally got what you mean. Right, so the command line conversion fails, while opening in Writer and saving as .odt works fine. I'm a practical man. Don't use the command line conversion method. ;) You might compare the .odt files - they're zip archives, so extract the contents to two different folders, then compare the two sets. Maybe you can file a bug report. See https://wiki.documentfoundation.org/Q... for help with that.

floris v gravatar imagefloris v ( 2021-01-15 16:31:25 +0200 )edit

Maybe it's an issue with the odt version that MS it's able to open fine, test saving with 1.2 not extended Menu/Tools/Options/Load&Save/General - ODF save version.

m.a.riosv gravatar imagem.a.riosv ( 2021-01-16 01:42:31 +0200 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2021-01-20 09:57:03 +0200

updated 2021-01-20 10:02:17 +0200

Yes, I repro MS Word 2016 unable to open an ODT produced from your DOCX sample from command line, while being able to open GUI-generated ODT. This is a bug in MS Word, which fails to read the document with missing optional style:column-width attribute of style:table-column-properties element in content.xml. The absence of the said attribute is normal and expected; it is only added when saved from GUI as a cached value to speed up following opening of the file (since when opened in GUI mode, LibreOffice processes the layout to show on screen, and thus has the calculated values ready, which is obvuiosly not performed in command-line version, which does not layout the document), and in its absence, application should just use style:rel-column-width to calculate the resulting column width.

See the reference in ODF standard; here is its RNG schema.

Nothing to be done on LibreOffice side.

edit flag offensive delete link more

Comments

MS documentation mentions this deficiency in [MS-OODF3]:

This attribute (i.e., style:rel-column-width - comment mine) is not supported in Word 2013, Word 2016, or Word 2019.

which means that they can't properly read valid ODF that only have relative column widths.

Also worth noting that in ODF up to version 1.1, there was some confusion in standard regarding requirement of style:column-width attribute: the schema told it's optional, while there was text stating otherwise:

15.9.1 Column Width

Every table column must have a fixed width. This width is specified by the style:column-width attribute.

The width of a column may be also specified relative to the other column widths.

This was corrected in ODF 1.2, which MS claims to support since Word 2013.

Mike Kaganski gravatar imageMike Kaganski ( 2021-01-20 14:53:24 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-01-15 15:03:59 +0200

Seen: 78 times

Last updated: Jan 20