-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
Trim duplicate objects #969
Comments
Is there any progress? from weasyprint import HTML
d = HTML('html.html').render()
d2 = HTML('html.html').render()
documents = [d, d2]
all_pages = [p for doc in documents for p in doc.pages]
documents[0].copy(all_pages).write_pdf('combined.pdf') I get dublesized pdf (2,8mb instead of 1,4mb) How to do such multipage optimization? |
A new
I think it was! |
Thanks. |
That’s it! |
I revisited and updated my code to add html = template.render(context=context)
# html is a long page contains of 1000 logos and 1000 QR codes (both png), totaling 200 A4 pages
image_cache = {}
doc = HTML(string=html, base_url="./")
doc.write_pdf("1.pdf", image_cache=image_cache) |
Hello! The feature added in this issue is the possibility to store only once the same images in the PDF when it’s created using multiple
You can try to use the current 53 beta version, because you’ll probably get better results. If |
I see, I'll try and report later. Any pointer to study the instructions in the generated PDF and how |
I've tried 53.0b2 but unfortunately it was a fail. |
That’s a big problem, but probably unrelated to this issue. Could you please open a new issue with a sample showing the problem? Thank you! |
Repo to reproduce this issue: https://github.com/leesei/WeasyPrint_1392 |
I'm using WeasyPrint to create lucky draw tickets, using a jinja template with images (logos and stuffs).
It seems WeasyPrint will embed the image for each instance rather then reusing the same object, resulting in a bloated PDF file.
I tried pts/pdfsizeopt: PDF file size optimizer and the file size is reduced to half.
Is is possible for WeasyPrint to have this optimization built-in?
The text was updated successfully, but these errors were encountered: