pdflibreofficepdfalibreoffice-draw

How to create a PDF/A from command line with Libre Office Draw in headless mode?


LibreOffice Draw allows you to open a non PDF/A file and export this a PDF/A-1b or PDF/A-2b file.

export as PDF

The same is possible from the command line by calling on macOS

/Applications/LibreOffice.app/Contents/MacOS/soffice --headless \
        --convert-to pdf:draw_pdf_Export \
        --outdir ./pdfout \
        ./input-non-pdfa.pdf

or an a Linux simply

libreoffice --headless \
        --convert-to pdf:draw_pdf_Export \
        --outdir ./pdfout \
        ./input-non-pdfa.pdf

On the command line it is possible to tell the convert-to to create a pdf and use LibreOffice Draw to do this by telling --convert-to pdf:draw_pdf_Export.

Is there also a way to tell LibreOffice to produce a PDF/A document in headless mode?


Solution

  • For PDF/A-1(means PDF/A-1b?):

    soffice --headless --convert-to pdf:"writer_pdf_Export:SelectPdfVersion=1" --outdir outdir input.pdf
    

    Change the value from 1 to 2 for PDF/A-2, here is the Libreoffice source code Common.xcs, pdfexport.cxx and pdffilter.cxx.