-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
SVG Image used as Logo is duplicated in PDF for every page #1978
Comments
Hi! Thanks for the report. That’s right, when a SVG file is drawn multiple times, it’s included multiple times. That’s not the case for raster images, because a cache is used to avoid this, and we reference the PDF’s XObject each time the image is drawn. We should be able (hopefully) to store the drawing once in the PDF and reference it each time it’s required. But I don’t know yet which PDF structure to use for that. |
Hello @liZe , I am experiencing the same issue. I generate documents with icons using an SVG spritesheet. However, it seems that the entire SVG is loaded each time an icon is retrieved:
From reading this discussion thread, I understand that the SVG is reloaded every time, which can result in a PDF document size of 4 MB for 14 pages. If I remove the icons entirely, the file size can decrease to 770 KB. Is there a planned update for WeasyPrint to address this issue? Thank you in advance |
There’s nothing planned for this issue. If you (or anyone) is interested in solving this issue, the first step is to find in the PDF specification a way to store the drawing once and reference it multiple times. |
Cou can use an svg image as a logo ( @page { @top-right{ background-image: url("/static/logo.svg")}} ) and it works just fine.
But if the document has > 1 pages, the full SVG resource is included for every page in the pdfs, blowing up its size greatly. (100 pages includes the svg 100 times).
I also tried defining the logo as a svg-symbol with an id and then loading the id with svg-use, but that doesnt show up at all.
WeasyPrint Version: 60.1
The text was updated successfully, but these errors were encountered: