pdfsvgpdfa

SVG transparency breaks PDF/A compatibility


Currently, I'm using mPDF to create PDF/A files in PHP. SVGs have a transparent background by default. But this breaks compatibility to PDF/A. When validation such a PDF file using veraPDF, I get an error, saying "A Group object with an S key with a value of Transparency shall not be included in a form XObject. A Group object with an S key with a value of Transparency shall not be included in a page dictionary"

enter image description here

I've tried to a add a rect to the SVG (like it is stated here) but have not had luck. Is there a solution to remove this transparency but still being able to use SVGs?

EDIT: I'm using simple FontAwesome icons as SVG, for example the globe. Looking at the SVG code I can't find any opacity or transparency style in it.

EDIT 2: I've uploaded a sample of a SVG and a resulting PDF file created with mPDF.


Solution

  • mPDF currently expects SVG will be transparent thus includes the following in its code.

    // Required for SVG transparency (opacity) to work
                $this->writer->object();
                $this->writer->write('<</Type /Group')
                $this->writer->write('/S /Transparency');
    

    For PDF/A-1B (in particular) that last line is not acceptable.

    Vera accepts the file if we blank out the /S/Transparency such that this is a pass ## 0 obj <</Type/Group >> endobj this would be a SIMPLE temporary workaround to keep EXACTLY the same number of bytes, to ensure no other fail.

    enter image description here

    The "simple" solution (if needing just 1B compatibility) is build a mPDF variant without that line from the SVG handler and any other of the few similar settings.

    Seen here https://github.com/search?q=repo%3Ampdf%2Fmpdf%20%2FTransparency&type=code