Roderick McMullen created BATIK-1379:
----------------------------------------

             Summary: Problems generating SVG with PdfBox PDFRenderer and Batik 
SVGGraphics2D for PDF with extended graphics state soft mask (/SMask), stroking 
alpha (/CA) and non-stroking alpha (/ca)
                 Key: BATIK-1379
                 URL: https://issues.apache.org/jira/browse/BATIK-1379
             Project: Batik
          Issue Type: Bug
    Affects Versions: 1.18
            Reporter: Roderick McMullen
         Attachments: batik-alpha-issue-180.zip, 
screen-capture-fully-transparent-column.png, 
screen-capture-mask-applied-twice.png, 
screen-capture-mask-not-shifted-up-enough.png

We subclass {{org.apache.batik.svggen.DefaultExtensionHandler}} to handle PDF 
soft masks when rendering to SVG with PdfBox (2.0.33) PDFRenderer and Batik 
(1.18) SVGGraphics2D.

Compared with the original PDF and rendered PNG created with pdfbox, the 
generated SVG looks different:

 * The computed soft mask recovered contains some unexpected, fully transparent 
rows and columns. (See attachment 
[^screen-capture-fully-transparent-column.png])
 * The alpha mask placement is (slightly) vertically misaligned compared to the 
PDF/PNG. (See attachment [^screen-capture-mask-not-shifted-up-enough.png])

How might these visual differences be avoided?

Additionally, the soft mask {{SVGPaintDescriptor}} object returned with this 
extension is applied to two SVG {{g}} elements (instead of one) which results 
more dramatic differences when compared to the PDF/PNG. (See attachment 
[^screen-capture-mask-applied-twice.png])

To work around this, our override to {{SVGPaintDescriptor.getAttributeMap()}} 
counts read attempts and returns an empty attribute map after the first use. 
What correction should we make to avoid needing this workaround? Or is this a 
batik issue?

Sample code, input PDF, and output SVG and PNG are included. (See attachment 
[^batik-alpha-issue-180.zip])



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to