Convert to PDF/A via LibreOffice Command Line
This guide explains how to convert office documents to ISO-compliant PDF/A archival formats using the LibreOffice command-line interface. It covers the required headless parameters, the JSON-based filter options for LibreOffice, and the exact profile values needed to output PDF/A-1b, PDF/A-2b, and PDF/A-3b files without launching the graphical user interface.
Command-Line Syntax
LibreOffice uses the --headless and
--convert-to flags to process files in batch or terminal
environments. To apply a specific PDF/A profile, you must append an
export filter configuration to the pdf format string.
The basic command structure is:
soffice --headless --convert-to 'pdf:writer_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"<PROFILE_NUMBER>"}}' input.docxNote: On some systems, soffice may be invoked as
libreoffice.
PDF/A Profile Values
The SelectPdfVersion property accepts an integer
corresponding to standard PDF and PDF/A versions:
0: Standard PDF 1.7 (default behavior)1: PDF/A-1b (basic archival compliance)2: PDF/A-2b (newer archival standard supporting transparency and JPEG 2000)3: PDF/A-3b (allows embedding of external file formats like XML or CSV inside the PDF)
Practical Examples
Convert to PDF/A-1b
libreoffice --headless --convert-to 'pdf:writer_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"1"}}' document.docxConvert to PDF/A-2b
libreoffice --headless --convert-to 'pdf:writer_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"2"}}' presentation.pptxConvert to PDF/A-3b
libreoffice --headless --convert-to 'pdf:writer_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"3"}}' spreadsheet.xlsxBatch Processing and Output Directory
You can specify an alternate output directory using the
--outdir parameter:
libreoffice --headless --convert-to 'pdf:writer_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"1"}}' *.docx --outdir ./pdfa_output/This processes all matching documents in the current directory and
places the validated PDF/A files into the ./pdfa_output/
folder.