Skip to content

Instantly share code, notes, and snippets.

@barryrowlingson
Last active August 29, 2015 14:22
Show Gist options
  • Save barryrowlingson/5a609113b79dc3540412 to your computer and use it in GitHub Desktop.
Save barryrowlingson/5a609113b79dc3540412 to your computer and use it in GitHub Desktop.
convert a bunch of docs to pdf
#!/bin/sh
for f in $* ; do
libreoffice "-env:UserInstallation=file:///tmp/LibO_Conversion" --headless --invisible --convert-to pdf "$f"
done
rm -rf /tmp/LibO_Conversion
@barryrowlingson
Copy link
Author

When converting documents from Libre/Open Office to PDF, it can connect to a running instance and then nothing happens on the command line. From http://ask.libreoffice.org/en/question/1686/how-to-not-connect-to-a-running-instance/ comes the -env trick of starting a new user installation. This script just does all the conversions in one go.

Copy to a directory in your path and do:

 topdf agenda.docx minutes.docx finances.docx

and voila, three PDF versions. Splat them together with pdftk *.pdf cat docs.pdf and you have one thing to take to the meeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment