WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

Handle more SVG filters

Open WBNet-Wout opened this issue 2 years ago • 2 comments

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

WBNet-Wout avatar Sep 11 '23 14:09 WBNet-Wout

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.

pmjdebruijn avatar Sep 13 '23 15:09 pmjdebruijn

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.

liZe avatar Sep 13 '23 17:09 liZe