-
-
Notifications
You must be signed in to change notification settings - Fork 686
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
Reproducible PDF generation #1553
Comments
The only reference for |
❤️
The PDF generation is not reproducible because of the way we handle fonts. The main problem is in fonttools (and may need a fix in foontools), but there’s also another "problem" in WeasyPrint (because of 8acedd3). |
I noticed a regression in this regards from v51 to v54.
And here is the diff from |
I also noticed that wp54 doesn't add the |
As a workaround for me, I'd pin wp to version 51 until this gets fixed, but is there a way to prevent the |
We actually changed the whole PDF generation library, that’s why you get an impressive diff. Things are thus not as easy as reverting the commits that introduced the regression.
You can include a meta tag in your HTML document to change this value: |
Awesome, thanks that worked! |
Wouldn't it be sufficient to make the "in PDF font hash" based on the font file file content, e.g. by replacing So the At least in my small "Hello World"-example it works with |
As far as I can remember, it works but it’s noticeably slower when a lot of fonts are included. It should be quite easy to find a solution to fix that though. But that’s not the only problem: Fonttool’s font subsetter is also not deterministic. We don’t know why yet. |
Do you have a example or link to an issue describing the problem in more detail? Maybe I can have a look into it. For my minimal example it was sufficient to set the environment variable |
You’re right, it’s probably the source of the variation, it looks like it’s reproducible with We now have two goals:
|
I didn’t know that |
We should now have reproducible PDF generation when |
@liZe Awesome! Happy to test a new release! |
However, it does not seem weasyprint is quite there yet. Although the
I believe when this feature is truly implemented, the following should output the same digest for each execution:
but right now, each execution will output a different digest. This is with weasyprint 57.0. |
OK, all is good now. I see that 2b05137 has fixed this issue. So I have pulled the most recent tip of the tree and the above test now works. How crazy that I happen to hit this one day after you fixed it the main branch and I had no idea! Thanks for fixing! |
Hi, first of all thanks for this awesome project!
I noticed that the PDF generation does create a different PDF from the same html each time.
Why is that ? I'm using this simple URL as an example because I noticed it first when generating PDFs from code which I check into git, and each time I run weasyprint I end up with a binary git diff for the PDFs. This is very unfortunate, because I want to only have a diff when I actually change sth in the code itself.
Is there any way/option to fix this ?
The text was updated successfully, but these errors were encountered: