How to convert doc/xls/ppt/… to pdf in Unix console
Wednesday, November 18th, 2009Today we needed to make a tool to convert Microsoft Office (and preferably other formats) documents to PDF from a Rails application. We have come up with such solution – install OpenOffice.org, CUPS and CUPS-PDF (virtual PDF printer for CUPS) and run it like this:
soffice -headless -pt Cups-PDF file.doc
This command executes OpenOffice.org in so-called ‘headless’ mode – meaning that it will not run anything graphical. It reads the file.doc, and prints it using CUPS-PDF virtual printer. The resulting PDF can be found (by default) in ~/PDF directory.