document conversion – Coffee and Code https://blog.coffeeandcode.com Thoughts on web development, collaboration, our local tech community, and probably tacos. Thu, 26 Oct 2017 18:04:30 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.3 Converting Documents with OpenOffice / LibreOffice https://blog.coffeeandcode.com/converting-documents-with-openoffice-libreoffice/ Mon, 09 May 2016 21:16:11 +0000 https://blog.coffeeandcode.com/?p=90 Continue reading "Converting Documents with OpenOffice / LibreOffice"

]]>
Did you know that you can convert documents with a headless version of OpenOffice or LibreOffice? If you pass a few commands to the soffice binary, you can convert one document type to another.

My examples will include paths for LibreOffice on a Mac, so make sure to adjust accordingly.

The following will convert all Word documents on my desktop to PDFs in the convert folder on my Desktop:

HOME=/tmp TMPDIR=/tmp /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir /Users/jon/Desktop/output/ /Users/jon/Desktop/*.doc

Make sure to include HOME=/tmp TMPDIR=/tmp before the command or it will run into permission issues and be unable to complete the file conversion.

Some believe writing files to the /tmp directory is a better approach, but I didn’t end up trying it myself.

Thanks to: https://ask.libreoffice.org/en/question/2641/convert-to-command-line-parameter/

]]>