Hi,

The annotation contains an appearance that is either provided or generated by PDFBox; in your file, it is provided. This is an ordinary PDF structure with a content stream etc. It uses a "multiply" blendmode. In PageDrawer.fillPath() it happens in

graphics.setComposite(graphicsState.getNonStrokingJavaComposite());

This is a blendcomposite that is created by

BlendComposite.getInstance(blendMode, (float) nonStrokingAlphaConstant);

more can be seen in BlendComposite.java and BlendMode.java.

I suspect that you'll have troubles with other PDFs that uses blend modes, e.g. the ones in
https://issues.apache.org/jira/browse/PDFBOX-4095
https://issues.apache.org/jira/browse/PDFBOX-3000

Tilman

On 13.02.2025 20:15, Rich Stafford wrote:
PDFBox users:

I have a simple PDF that contains some text, and an 'annotation' highlight 
covering the text.  Using PDFBox 3.0.2, when I render it to a raster format, 
the 'annotation' is transparent and the text behind it shows up.

However, when I render it to SVG (using batik svggen.SVGGraphics2D), the 
highlight is opaque.

I've put the sample PDF and the generated SVG in a public folder as follows:

PDF:            s3://webdl.equorum.com/misc/I20250156.pdf
SVG original:   s3://webdl.equorum.com/misc/I20250156.svg
SVG opacity:    s3://webdl.equorum.com/misc/I20250156-opacity.svg

The highlight is rendered as a 'g' object in the SVG near the end of the file, 
with a 'fill:rgb(255,255,49)'. If I add a 'opacity:0.4;' attribute to that 
object, then the contained text appears properly. The I20250156-opacity.svg has 
been modified to add the opacity attribute.

I guess what I need to find is what rendering call from PDFBox is being made to 
render the 'annotation' highlight.  I've already sub-classed the SVGGraphics2D 
class to handle some other image related issues, so hopefully I can find the 
corresponding calls to handle this as well?

Thanks for your assistance,

Rich Stafford
Chief Scientist
eQuorum Corporation



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to