Archive for April, 2012

Converting Microsoft Word documents to PDF programmatically – server side.

We couldn’t find one plain and simple example on the web so we’re posting it here in case it helps someone. Our requirements:

converting DOC and DOCX to PDF from command line, server side.
No X of course. (LibreOffice excluded).
Not just DOC (Antiword excluded).
Debian packages whenever possible (python-docx excluded).

Log in to your server:

sudo apt-get install abiword
abiword --to=pdf --to-name=<your_document_name.pdf> <your_document_name.docx>

That should give you “your_document_name.pdf”. We’re just interested in extracting text, so we’re not sure about format quality.

Enjoy!