Kozea / WeasyPrint

The awesome document factory
https://weasyprint.org
BSD 3-Clause "New" or "Revised" License
7.1k stars 678 forks source link

Handle more SVG filters #1962

Open WBNet-Wout opened 1 year ago

WBNet-Wout commented 1 year ago

With below HTML the embedded SVG is not properly rendered when converted to PDF using WeasyPrint.

test.html

In a browser it looks like this (note the GLS logo at the bottom right):

image

In a PDF generated by WeasyPrint it looks like this instead:

image

pmjdebruijn commented 1 year ago

What immediately stands out, is that the problematic area isn't actually a vector, but an embedded (greyscale, PNG) bitmap. And it gets weirder, extracting the bitmap, shows it's actually being inverted on the fly.

But the better solution might actually be to replace the bitmap data with a traced vector.

Sidenote: I don't think you need to base64 encode an SVG, SVG is allowed directly into HTML these days.

liZe commented 1 year ago

The problem is that some SVG filters are not handled (namely feColorMatrix in your example).

Here’s a smaller file adapted from your example: svgtest

I don’t know what’s possible to do in PDF, but I suppose that it’s possible to handle more primitives. If someone is interested, two of them are handled in apply_filters.