Convert OpenXML (.docx, etc.) in Linux using command line - Ninja

Convert OpenXML (.docx, etc.) in Linux using command line

Posted by Andrew Z at Monday, January 7, 2008 | Permalink

Microsoft Office 2007 came out about a year ago. Have you yet started getting .docx, .xlsx, or .pptx files? Whether you are an user or a Microsoft Office 2003 user, you are probably frustrated trying to find some way to convert, import, or otherwise open these documents.

These new document formats are called Office Open XML, OOXML, or OpenXML. They are significantly different from the Microsoft Office 97, 2000, 2003, or XP formats. The new formats are based on XML while the old formats are binary.

If you don't use Linux or you are afraid of the terminal, skip to the very end. Otherwise here is one easy way to convert these documents thanks to Novell. They developed a tool called the OpenOffice OpenXML Translator, and soon it will be fully integrated into the mainstream

Because this procedure is for the command line (and does not directly integrate into the vanilla, this procedure is well suited for automated, batch conversions between OpenXML and OpenDocument Format. This procedure should work on all Linux distributions: Ubuntu, Fedora, SUSE, Mandriva, Debian, and so on.

Installation prerequisites

Install the programs rpm2cpio and cpio. If you run a system such as Fedora, run this command:

sudo yum -y install cpio rpm

If you run Ubuntu, run this command:

sudo apt-get install rpm libgif4

Installation procedure

The general idea is the same no matter which Linux distribution you use. You are basically copying one file out of the RPM as if it were a tarball or a zip file. You are not installing the RPM in the traditional sense, so don't worry if you run a non-RPM-based system such as Ubuntu, Debian, or Slackware

  • Download odf-converter-1.1-7.i586.rpm for i386 systems or odf-converter-1.1-7.x86_64.rpm for x86_64 systems.
  • Open a console.
  • Change directory to your download directory. Depending on your setup, it may be: cd ~/Desktop
  • To unpackage the rpm, run this command: rpm2cpio odf-converter*rpm | cpio -ivd
  • To copy the binary run this command: sudo cp usr/lib/ooo-2.0/program/OdfConverter /usr/bin
  • Optionally you may now delete the opt and usr directories you just unpacked as well as the .rpm file you downloaded. However, you may wish to keep the files under usr if you are interested in documentation and sample OpenXML documents.


The usage is simple. To convert a .docx file (Word 2007) to a .odt (OpenDocument Format) file, just run:

OdfConverter /i example.docx

Then, you will find the .odt file in the same directory as the .docx. Then, open the ODF file in or your favorite office suite.

For more help on arguments, just run OdfConverter without arguments. If you are curious, there are some OpenXML sample documents included in the RPM: check the directory usr/share/doc/packages/odf-converter/.

Related articles


Anonymous said...

Thank you so mach!

Andrew Z said...


You're welcome!

Anonymous said...

On thing to always keep in mind is that OOXML is a broken format and the user sending files in this format should be warned about this. See more on NoOOXML.

Anonymous said...

helped a lot!


Test said...

Trying to run it on CentOS, and I'm getting:

OdfConverter: error while loading shared libraries: cannot open shared object file: No such file or directory


Andrew Z said...


Here is the command (which you can enter in a terminal) to find which package you need:
sudo yum whatprovides

Here is how to install the necessary package:
sudo yum install giflib


Anonymous said...

I'm trying to run this in ubuntu, but i get:

OdfConverter: error while loading shared libraries: cannot open shared object file: No such file or directory

how can i resolve this?
many thanks!!

Anonymous said...

ok i figured it out.

by running "locate" I found that i have

so i made a symbolic link with
"sudo ln -s /usr/lib/ /usr/lib/"

then a bit of "sudo ldconfig" to update the library cache and bob is now my uncle

i'd love to take credit for that bit of wisdom but i actually found it here:

thanks for the guide, it's a real treat

Anonymous said...

Josiah Yoder said...

thanks, jeremo. That fixed my problem!

Anonymous said...

I've just installed it, but I only get

bash: /usr/bin/OdfConverter: cannot execute binary file

any help?

Andrew Z said...

@anonymous: Which Linux distribution do you use? Is it 32-bit or 64-bit? Do you have the 32-bit libraries installed? Have you tried searching for the error?

Anonymous said...

thanks to everyone's help (especially jeremo's follow up) I was able to get this running on Ubuntu as well...turns out google-earth had and i just copied it into /usr/lib ...don't get confused when you run OdfConvert and it doesn't work, it's "OdfConverter" :)

agy said...

thanks for all

it's great to be able to find whatever you want in linux.
Linux forever

Unknown said...

To unpackage, I had to filter through bunzip2:

rpm2cpio odf-converter-*.i586.rpm | bunzip2 - | cpio -ivd

Debian 4.0

Anonymous said...


This worked fine on Fedora 8 and default OpenOffice.

I had to 'rpm -i --nodeps odf-convertor...' because it complained about openoffice not being > 2.0 (which it is: 2.3)

Thanks, it was a big help.

oub said...

Mathematical equations are not

Hello, I wrote a ODT file, containing enumerated list, tables colors and mathematical formula. I converted it to docx format.

- I could not open that file with the Oygen Openoffice which contains a docx import filter, files corrupted.
- converted the docx file back to odt, but then the math formula were gone.

can anybody comment on this?

TJ Davis said...

Thanks a lot, this is REALLY helpful. I was using zamzar to convert and that works but is slow with the free account.

One suggestion to make it easier. If you prefer GUI rather than CLI you can right-click on a docx file and say "open with" then choose custom command. For the custom command type "OdfConverter /i" After that you can go to properties of any docx file and go to the "Open With" tab and choose OdfConverter as the default program. From now on, when you click to open a docx it will not open it but will instead spit out a odt file in the same directory which you can open. This works well in Gnome/Nautilus. I am sure the instructions are slightly different in KDE/Konqueror.

SimonB said...

No joy with PCLinuxOS 2007 yet. This is similar to Mandriva.

I get
error: Failed dependencies:
OpenOffice_org >= 2.0 is needed by odf-converter-1.1-7.i586 is needed by odf-converter-1.1-7.i586

OO is installed, just has a different package name. Same with libgif, since is present in the /usr/lib directory.

If I install with nodeps I get
/var/tmp/rpm-tmp.6321: line 22: SuSEconfig: command not found

When it finishes there is no file called OdfConverter installed in /usr/bin.

Andrew Z said...

BK SimonB: Did you install OdfConverter with "rpm -Uvh ...."? You aren't supposed to do that unless you run the Novell version, so please read the instructions again.

Anonymous said...

In order to get the conversion in the action context menu under KDE/Konqueror you need to do two things
1. save the following as $HOME/.kde/share/apps/

#Word XML>Openoffice.odt
[Desktop Entry]

[Desktop Action docx2odt]
Name=Convert XML to Openoffice .odt
Exec=Odfconverter /i %f

2. create an application/mswordXML mimetype by
Control Center -> KDE Components -> File Associations -> Add... Group = applications, Type Name = mswordXML, Filename Patterns = *docx

bhups said...

Is it necessary to have openoffice installed on the system before using OdfConverter?
I am able to convert pptx into odp's but the output is not good enough i.e. in lots of slides TEXT in the slide is getting clipped.
So is OdfCoverter somehow dependent on OpenOffice i.e. some schema files, it looks for in oo installation directory?

Andrew Z said...

dmk: I was thinking of something like that, and you encouraged me finally to do it. Check out odf-converter-integrator which should be usable in the next few days.

bhups: odf-converter is completely independent of, and you can use odf-converter if is never installed. Check odf-converter on how to report a bug

Anonymous said...

SWEET! Thanks! This worked like a champ :)

Jacques Charroy said...
This comment has been removed by the author.
Anonymous said...

A cool thing this converter :) . BTW, in your guide you're mentioning "OdfConvert" instead of "OdfConverter" command. I spend a few minutes figuring out what's the problem with the command:).

Tried with SuSe 10.1

Andrew Z said...

Jan: Thanks. I fixed it and made a few updates.

Anonymous said...

Is there any other conversion tools available for the common office formats(XLS,DOC,), like this handy docx converter?
I need them as concole apps on linux server whitout installed.
Thanks for any help!

Anonymous said...

Hi to all! Thanks for a cool thing, but there's a small problem. It takes time to write some junk to log (I mean "[INFO]...process:cprocess:cprocess" and etc.) I use odf-converter to process very big amounts of data (I convert xlsx files to ods). Could you help me to get source code of converter ? I'd like to stop using method AddLog(), that writes log according to the /LEVEL parameter. I'm very-very-very need in this code! Please, help me.

Andrew Z said...

Kseniya: The source code is here

Anonymous said...

Just FYI, but the latest OpenOffice (2.4.1) included with Ubuntu (Hardy Heron & above) seems to open docx files *natively* (Office 2007 format)...

Though oddly enough the same version of OO in Windows won't open the file(?!) o_O

Andrew Z said...

Boo: Ubuntu ships a heavily modified version of In some ways it is even a fork. Some of the features are great, but I've seen scores of report of significant bugs specific to Ubuntu OOo/Go-oo/ooo-build (same thing basically).

You can also get something similar for Windows from, but on all my systems I use the vanilla edition.

Last time I checked about six months ago, the odf-converter and odf-converter-integrator had a higher quality of conversion than Ubuntu (which was a backport of the OOo 3.0 alpha code).

Anonymous said...

for gentoo you can use rpm2targz to convert the rpm to tar.gz.
in case you get the message: you need giflib

Anonymous said...

Thnx for the nice tutorial! really helpful...keep it up!

Health Insurance Quotes

Unknown said...

Thank you, after linking a library in Ubuntu 8.04 (Hardy Heron) by
sudo ln -s
OdfConverter works

Unknown said...

Many thanks for docx converter.
Work nice!


Anonymous said...

Use and convert your Files for free. thats it! I did this coz my was non-existent or whatever.

Andrew Z said...

Abhinit Tiwari: The new odf-converter-integrator 0.2.0 released this week doesn't require anymore.

Robin said...

I'm really grateful for this tutorial - thanks.

Does anyone know a command line tool for converting xlsx to csv (the file has more rows than OOCalc can handle)?

I was wondering about a xsl translation kit for OOXML...

Anonymous said...

I have a much easier and simpler solution for those of us who aren't so tech savvy.

From a gmail account, attach the docx file and send it to yourself or to another gmail account.

When you receive it you can view it as html, then just copy and paste.

It's not perfect, you'll have to do some ironing out of the format, but I found it much easier than trying to install programs & dependencies etc.

P.S. After this process send an email to the eedjit who sent you the docx telling them how irritating it is!

Andrew Z said...

Anonymous: Even easier than Gmail is odf-converter-integrator. It converts docx/xlsx/pptx files with a click.

Anonymous said...

Data Transformation Server includes and or supports pre-built adapters for ASCII flat files, Microsoft Excel, Fixed-length files, complex XML messages and EDI

Anonymous said...

Thanks a lot.

No problems on Fedora 8

Anonymous said...

Please donate your old boxes to a church-group or some needy student in these hard times! To comply with the law, and with Microsoft's leasing policy, you can now replace Microsoft OS with the free (download from the net) Ubuntu OS, which can be set to erase the hard drive of all traces of the “illegal to give away ” Microsoft system and your private information, before donation! Now, explain to your lucky recipient that all the manuals they will ever need are available for free on the internet! Just ask for them in Google! OpenOffice, which is installed already is plenty adequate for homework assignments and with a little exploring, everything else can work well too! Happy computing!

Unknown said...

Yes man, it works!! Thanks for your post, it helps me a lot.

All the best,

Unknown said...

This helped me immensely, thanks for posting it. Also big thanks to jeremo. I don't think I would have gotten this working without his post.

Anonymous said...

Did helped me too
saved my day actually

Anonymous said...

If you want to output PDF, you may also wish to consider anytopdf, a perl based script that wraps and installs the macros for you.

Usage: anytopdf <infile> <outfile.pdf>

oub said...


I just visted that side:
anytopdf has no download candidate

Uwe Brauer

Pitro said...


btw. it's not a very good idea to make link from to you better download, and build the libtiff3 package. it's not in Ubuntu packages anymore, but it is here:

also you may want to replace the link to odfconverter above that points to that specific version with a link pointing to download directory... there is a new version from April laying around.

Sumit Asok said...

Even easy method...

Upload the file into Googlem Docs...and download it in the format you wish to...

I appreciate your work sir, i just mensioned an even easy method for " those who are afraid of command line..."

Keep your works on...

Take Care
Sumit Asok

esilver said...

FYI - simply linking as didn't work for me -- the converter would hang -- so I had to install by building it from source here:

Chandrasekar Padmanabhan said...

Below link is broken

Is any other link available to download the same?

I already downloaded the rpm using the below link

Chandrasekar Padmanabhan said...

Is there any odf-converter-integrator rpm download for centos 64 bit linux?

I searched it in the below link.

Any help appreciated

Andrew Z said...

Chandru: For now you need to use the 32-bit version on 64-bit systems.

Anonymous said...

Thanks! I get this error message when trying to install the converter:

$ rpm2cpio odf-converter-1.1-7.i586.rpm | cpio -ivd
argument is not an RPM package
cpio: premature end of archive

Andrew Z said...

xi\'an: Your download may be incomplete, so try downloading again

Anonymous said...

It worked. Thanks a lot.

MarceloSegura said...

How can I uninstall the plugin? I see it created copies in multiple places of my computer (running peppermint linux)

Jannik said...

Installation in Ubuntu 64Bit:

1. sudo apt-get install rpm libgif4
2. wget
3. rpm2cpio odf-converter*rpm | cpio -ivd
4. sudo cp usr/lib64/ooo-2.0/program/OdfConverter /usr/bin
5. sudo ln -s /usr/lib/ /usr/lib/
6. sudo ldconfig