11

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?

saw303
  • 8,051
  • 7
  • 50
  • 90
  • 1
    Have a look at https://stackoverflow.com/questions/62535317/converting-docx-to-pdf-a-with-libre-office-writer . There is no such thing like a cli option. I guess, that uconv fiddles with the user settings file (registrymodifications.xcu) that stores the pdfa options before triggering headless libreoffice. And that seems to get read by libreoffice, even in the headless mode. – stefan.seeland Sep 22 '20 at 13:04

2 Answers2

4

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.

schemacs
  • 2,783
  • 8
  • 35
  • 53
  • 1
    Note that despite there *was* a SelectPdfVersion filter data element, it was *never* possible to define it using command line prior to version 7.4 (not yet released at the time of writing my comment) - see https://ask.libreoffice.org/t/solved-convert-to-pdf-with-specific-settings-from-command/40192/4 that mentions respective enabling commit. So this accepted answer is wrong, and the *working* syntax in 7.4 will be `soffice --convert-to 'pdf:writer_pdf_Export:{"SelectPdfVersion":{"type":"long","value":"1"}}' input.pdf` – Mike Kaganski Feb 24 '22 at 07:17
  • @Mike Kaganski How is it possibile *version 7.4* ? Now, August, the stable release is 7.2.7 and the fresh one is 7.3.4 – Massimo Jul 20 '22 at 12:39
  • 1
    @schemacs Did you find a working solution? I tried yours and Kagansky one, they don't work. – Massimo Jul 20 '22 at 12:40
  • @Massimo If you read my comment, you may note the "not yet released at the time of writing my comment"; 7.4 is in release candidate stage at this moment (and was a pre-alpha back then in February when I was writing that); its release is due in Aug (https://wiki.documentfoundation.org/ReleasePlan/7.4). – Mike Kaganski Jul 21 '22 at 13:09
1

Since with LibreOffice is possibile only via GUI, for command line solution use gs

  • First convert pdf to ps
pdftops input.pdf input.ps
  • Then convert ps to pdf/a archival format of PDF
gs -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sProcessColorModel=DeviceCMYK -sDEVICE=pdfwrite -sPDFACompatibilityPolicy=1 -sOutputFile=input-A.pdf input.ps
Ax_
  • 803
  • 8
  • 11