rototor / pdfbox-graphics2d

Graphics2D Bridge for pdfbox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stop-opacity on linearGradient stops are not rendered

iocoker opened this issue · comments

SVG files with stop-opacity inside a stop are not rendering correctly. EG:

<linearGradient> <stop stop-color="#3f2600" stop-opacity="0.6" offset="0" /> <stop stop-color="#3f2600" stop-opacity="0" offset="1" /> </linearGradient>

Will render a uniform opacity of 0.6

tux

So, something like the Tux SVG above renders like this:
Screenshot 2022-05-01 134104

@iocoker Thats a difficult issue. PDF does not support opacity gradients. At least not in PDF 1.7 (no idea about PDF 2.0; Did not yet pay for the spec... but likely not).

So this can only be faked somehow. Some common way to fake it, is to just rasterize the gradient as image. But this increases the file size a lot and also looks bad depending on the resolution used to rasterize the gradient...

Maybe it is possible to somehow implement that using soft masks. I'll have to investigate that.

@rototor , thanks for the reply.

The SVG is actually drawn into this sample and Acrobat reports its version as 1.7.
Sorry I'm not an expert on PDF, it could well be a 2.0 feature, as most PDF viewers are forgiving

example_058.pdf

@iocoker I see, yes that is possible with PDF 1.7. In this example it uses a SMASK for the gradient masking.

I "just" need to replicate that.