How to convert Microsoft Office *.docx files to PDF using Linux in command-line

Here’s how to convert Microsoft Office *.docx files to PDF using Linux in Command Line.
This trick can also be used together with other documents files supported by LibreOffice

First make sure you’ve installed the latest version of LibreOffice for use in command line environment.
Assuming the user is ‘example’ and the filename to convert is ‘doc.pdf’.

libreoffice --headless -convert-to pdf --outdir /home/example/ /home/example/doc.docx

The conversion can also be adapted to PHP or Python using their respective shell_exec or subprocess directive.

How to convert *.docx files (Microsoft Office 2007) online for free

Sometimes you might have no choice except to open Microsoft Office 2007 (*.docx) files that you’ve just received in your email. The problem is, you do not have any other application that support Office 2007 format.

Here’s an easy way to (kinda) solve that problem, you can convert Microsoft Office 2007 files online, using Google Docs.

Google Docs Logo

The steps are easy, you need to login into your Google Docs account, then upload the Office 2007 files. After that, you can choose the “Download file as” option to convert the file to your favorite document format (typically OpenDocument or older *.doc Microsoft Office word document).

Bear in mind that the conversion is not 100% perfect and there will be parts of document that won’t look exactly as the original ones.

Upcoming OpenOffice.org 3.0 supports Microsoft OpenXML (docx) out of the box

The popular Free and Open Source Office application, OpenOffice.org is going to have OpenXML (*.docx, *.xlsx, *.pptx) support by default. Scheduled to be release on September 2008, OpenOffice.org 3.0 packs a lot of features you might find interesting :

openoffice 3.0 development release
  • Import PDF files support. PDF documents can be edited in Writer
  • Official Mac OS support, now includes native “Aqua” interface
  • Multiple page view in Writer
  • Error bars in OpenOffice.org charts
  • Supports OpenDocument 1.2 specification

The BETA is scheduled to be released on April 30th, 2008. For the time being, OpenOffice.org 2.x users can open Microsoft OpenXML files (*.docx, *.xlsx) using odf import filters

Thanks to Andrew Ziem for the original article, OpenOffice.org 3.0 new features, an early look