Search code examples
ghostscriptpdfazugferd

Can't create ZUGFeRD documents with colored transparent images


we have some problems getting valid ZUGFeRD documents with ghostscript. It is possible that our customers add some images or their brand logo with transparency to their invoices.

Now we are running into a problem.

Transparencies are defined as SMasks which needs to be DeviceGray. So if I understand it correctly we are not allowed to convert the document to RGB.

For example with this call:

gs -dPDFA=3 -sDEVICE=pdfwrite -dNOSAFER -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=0 -sZUGFeRDXMLFile=path_to_xml -sZUGFeRDProfile=path_to_default_rgb_icc -o output.pdf ./data/zugferd.ps input.pdf

This throws the error Detected SMask which must be in DeviceGray, but we are not converting to DeviceGray, reverting to normal PDF output.

As already mentioned this is the correct behaviour. I've read the bug entry here https://bugs.ghostscript.com/show_bug.cgi?id=707450

Now to my problem. As far as I understand (and what I read in the zugferd.ps file) that I am only allowed to set RGB, CMYK or Gray for sColorConversionStrategy.

Which leads to my assumption that I am not allowed to use colored transparent images in ZUGFeRD compliant documents.

Or did I overlook something?

Thanks in advance and best regards,
Dominic


Update #1

Regarding KenS comment:
Updated ghostscript to latest available version (10.04.0). The error is not present anymore - thanks to this. But now I run into the same error as mentioned here: https://bugs.ghostscript.com/show_bug.cgi?id=708066

If I read and see it correctly, the mentioned commit https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/?id=5d9b000c70f66f5be7bfaed1f16ef4e50d820dc6 is not present in any release yet. Any plans?

Also after updating to latest version I get an exception verifying the document with verapdf:

Exception: Caught unexpected runtime exception during validation caused by exception: class org.verapdf.cos.COSIndirect cannot be cast to class org.verapdf.cos.COSDictionary (org.verapdf.cos.COSIndirect and org.verapdf.cos.COSDictionary are in unnamed module of loader 'app'). But I don't know if this is related to the update or related to something in my document. (Can't share the current document cause it contains sensitive data). Might need to create another example which I can share.


Solution

  • Finally and thanks to @KenS I was able to have a solution to my problem.

    I'm not able to get the latest master branch built for alpine linux. It would take too much time to find a solution to this - which I don't have.

    So I took the latest release (10.04 for now), which I am able to build for alpine and patched in the following commit -> https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/?id=5d9b000c70f66f5be7bfaed1f16ef4e50d820dc6

    The result is a fully valid PDF/A-3 document and also Adobe sees the attachment now.

    So until 10.05 will be released in march this is fine for us.