Skip to content

Instantly share code, notes, and snippets.

@flowinho
Last active May 19, 2021 14:00
Show Gist options
  • Save flowinho/edcee6829e4128b1c66a8500b8d0d2d6 to your computer and use it in GitHub Desktop.
Save flowinho/edcee6829e4128b1c66a8500b8d0d2d6 to your computer and use it in GitHub Desktop.
Convert all pdf in a directory to PDF/A using LibreOffice

The headless version of libreoffice uses the PDF settings you define using File -> Export as PDF (not directly export) Adjust the settings you need there, PDF/A 1b is sufficient for most cases.

Basic headless command

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless

Tell libreoffice to convert to PDF

--convert-to pdf:writer_pdf_Export

Define output directory

--outdir ~/Desktop/output

Define input directory / file, supports batch-import of all files of a type Please note: I could not find out a way to support recursive directory loops

~/Desktop/output ~/Desktop/testing/*.pdf

The full example command

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf:writer_pdf_Export --outdir ~/Desktop/output ~/Desktop/testing/*.pd

Profit 🍻

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