Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle more SVG filters #1962

Open
WBNet-Wout opened this issue Sep 11, 2023 · 2 comments
Open

Handle more SVG filters #1962

WBNet-Wout opened this issue Sep 11, 2023 · 2 comments
Labels
feature New feature that should be supported

Comments

@WBNet-Wout
Copy link

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
Copy link
Contributor

pmjdebruijn commented Sep 13, 2023

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 liZe changed the title SVG not properly rendered Handle more SVG filters Sep 13, 2023
@liZe
Copy link
Member

liZe commented Sep 13, 2023

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 liZe added the feature New feature that should be supported label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

No branches or pull requests

3 participants