Ahmed Tarek
Ahmed Tarek

Reputation: 53

Using ghostscript and facturx library in python to create factur-x PDF/A-3 compliant (Zugferd)

first of all I read the documentation here Creating a ZUGFeRD pdf to have a Zugferd PDF/A-3 pdf compliant :

  1. Created a custom .ps you can check it here PDFA_def.ps as mentioned in Zugferd documentation and used this color profile sRGB.icc.
  2. I wanted to convert this pdf invoice (sample) RE.__2021_0002.pdf to PDF/A-3 compliant
  3. In order to convert this sample invoice to Zugferd PDF/A-3 compliant i used this command from ghostscript gs -dBATCH -dNOSAFER --permit-file-read=${PWD} -sDEVICE=pdfwrite -dPDFA=3 -sColorConversionStrategy=RGB -sPDFACompatibilityPolicy=1 -sZUGFeRDXMLFile=${PWD}/factur-x.xml -sOutputICCProfile=${PWD}/sRGB.icc -sOutputFile=${PWD}/RE.__2021_0002_pdf3a.pdf ${PWD}/PDFA_def.ps ${PWD}/RE.__2021_0002.pdf
  4. I used veraPDF to check if the resulting pdf file is PDF/A-3 compliant but it showed that it's not PDF/A-3 compliant enter image description here

Then I used facturx library in python to generate RE.__2021_0002_factur-x_embedded.pdf invoice containing factur-x.xml embedded inside then i used this command from ghostscript to convert it to PDF/A-3 compliant gs -dPDFA=3 -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sProcessColorModel=DeviceCMYK -sDEVICE=pdfwrite -sPDFACompatibilityPolicy=1 -sOutputFile=RE.__2021_0002_factur-x_embedded_pdf3a.pdf RE.__2021_0002_factur-x_embedded.pdf

But unfortunately, the resulting pdf is not PDF/A-3 compliant enter image description here and it also lost the embedded factur-x.xml after this command.

I checked most of the questions here in StackOverflow regarding this topic, for example here, and tried the commands and read the comments but it didn't work too.

Update: The resulting pdf is not compatible with neither PDF/A-3a nor PDF/A-3b.

I need to know how to properly make the pdf invoice PDF/A-3 compliant?

Thanks.

Upvotes: 1

Views: 1346

Answers (1)

Ahmed Tarek
Ahmed Tarek

Reputation: 53

Before reading my answer please also consider looking at the comments on my question from @KenS . Thanks @KenS for your contribution! I could convert regular pdf to PDF/A-3b using the command and it worked:

gs -dPDFA=3 -dBATCH -dNOPAUSE -dNOSAFER -sColorConversionStrategy=UseDeviceIndependentColor -sDEVICE=pdfwrite -dPDFACompatibilityPolicy=3 -sOutputFile=<outputfile> <inputfile>

And i used -dPDFACompatibilityPolicy=3 according to the answer here by @exa So for me the problem was solved by using the option -sColorConversionStrategy=UseDeviceIndependentColor

Upvotes: 1

Related Questions