Convert Word files to PDF without Word

January 10, 2019

I have a Mac which does not have Microsoft Word installed. Clicking on a docx file will open it in Apples Pages, which usually can read and display it, but most of the time I just want to convert the file to a more Portable Document Format.

Prerequisites

To solve this, I turned to Pandoc, an amazing utility that can convert to, and from, a huge number of formats. It is easy to install on MacOS with Homebrew.

brew install pandoc

If you use Windows or Linux, please read the installation instructions.

Convert to PDF

Pandoc can guess what format to convert to based on the file extension, so the command to convert example.docx to PDF is quite simple.

pandoc example.docx -o example.pdf

Landscape

The above command always generates a PDF with portrait layout. A quick search guided me to a solution for how to generate a pdf with landscape layout. It turns out that adding the flag -V geometry:landscape fixes that.

pandoc example.docx -V geometry:landscape -o example.pdf