1

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.

  • You've validated the Ghostscript produced PDF file against PDF/A-3a using Vera PDF. Ghostscript will **not** produce 'a' variant files, only 'b'. So you need to verify against PDF/A-3b. I can't comment about the factur-x library. – KenS Mar 16 '21 at 17:21
  • 1
    @KenS thanks for your reply, it's neither compliant with PDF/A-3a nor PDF/A-3b – Ahmed Tarek Mar 16 '21 at 17:25
  • 1
    Well there are a few problems with your command line; you've specified -dNOSAFER and --permit-file-read, you don't need both and I would suggest you do not use -dNOSAFER. You say you have used -sPDFACompatibilityPolicy=1, but that will produce an error because it should be -d not -s. Your pdfa_def.ps file does not apparently give a fully qualified path to srgb.icc which it should. What version of Ghostscript are you using ? I'd start by just going for a PDF/A3b file and worry about zugferd after that. If I fix the problems above I get a valid PDF/A-3b file verified by VeraPDF. – KenS Mar 16 '21 at 20:25
  • 1
    Oh and you should not specify -sOutputICCProfile either. With srgb.icc in d:/temp, pdfa_def.ps modified to include the path to srgb.icc and my command line: -sDEVICE=pdfwrite -o out.pdf -dPDFA=3 --permit-file-read=d:/temp/ -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 pdfa_def.ps "RE.__2021_0002 (1).pdf" I get a valid file. – KenS Mar 16 '21 at 20:26
  • @KenS thank you and i want to ask you after you got a valid file, does that file include factur-x.xml file embedded inside ? – Ahmed Tarek Mar 16 '21 at 21:00
  • No, as I said I focused at that point in creating a valid PDF/A3 file, I think you should start by doing the same. Once you have a valid PDF/A3 file you can move on to creating a Zugferd file. I do know that it is possible to do this, at least 2 different users have created valid zugferd files using the documentation. Obviously these were people who asked questions, I don't know if others have followed the process without asking questions. – KenS Mar 17 '21 at 13:28
  • I managed to convert pdf to PDF/A-3b using the option -sColorConversionStrategy=UseDeviceIndependentColor I used the command gs -dPDFA=3 -dBATCH -dNOPAUSE -dNOSAFER -sColorConversionStrategy=UseDeviceIndependentColor -sDEVICE=pdfwrite -dPDFACompatibilityPolicy=3 -sOutputFile= – Ahmed Tarek Mar 18 '21 at 08:26
  • Is the ICC mandatory? I don't understand why it's in the "minimal command" to produce a PDF/A-3 with an embedded XML (aka ZUGFerd Factur-X). – Sandburg Oct 28 '22 at 10:39

1 Answers1

1

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