BenV's notes

Commandline XLS/DOC to PDF converting

by on Apr.04, 2011, under Software

Since this took me 5 years to find through google, this is another reference post.
Converting word and/or excel documents to PDF format should be easy.
Unfortunately it takes Libreoffice (or whatever your variant is today), but it works:

$ libreoffice -headless -convert-to pdf /tmp/bla.xls
convert /tmp/bla.xls -> /tmp/bla.pdf using calc_pdf_Export

No garbage paid for converters needed, just garbage libreoffice.

Update: since libreoffice is still the same garbage as openoffice (maybe it’ll improve some day) I ran into this error
on my production machine:

$ libreoffice -headless -convert-to pdf /tmp/bla.xls
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!

Apparently this is caused by libreoffice wanting to do some garbage in its home directory. Except for my headless user doesn’t have a workable home.
Oh yeah, there’s a -nofirststartwizard option but it doesn’t help. This is solved by setting HOME to /tmp for instance:

$ HOME=/tmp libreoffice -headless -convert-to pdf /tmp/bla.xls

Leave a Reply

You must be logged in to post a comment.


  • 2018 (1)
  • 2016 (1)
  • 2015 (7)
  • 2014 (4)
  • 2013 (11)
  • 2012 (27)
  • 2011 (26)
  • 2010 (25)
  • 2009 (68)