-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Check for unmatched doc.restore() calls? #271
Comments
Hmm, yes. Right now most commands get rendered directly into the document as soon as you call them, but I'm thinking of moving to a model where calls are batched and can be more easily checked for user error. Thanks for reporting. I didn't know Acrobat complained about this. |
I just encounter this error as well, seems like acrobat still fails on it. (browsers are ok, OS X preview too, as well as affinity publisher). |
This happened to me recently, I found that:
I tried printing at a chain printshop and it choked on the pages: The code to generate the PDF is quite involved and superficially I see an equal number of Regardless, thanks for all the work on this, it’s much nicer to work with than the hideous hacks I was using in the past 😬 ETA: I added this hack to track the save/restore stack:
The last line logged is this: So it does seem like they balance out! I’m sure I did something wrong somewhere but I’m not sure how to track it down. |
It's easy to produce a corrupt PDF by inserting a stray unpaired doc.restore() into code that uses pdfkit.
Is checking for stuff like this something pdfkit should try to do?
These errors are hard to detect because the resulting file renders without error in the better PDF viewers out there, including Preview and pdf.js. Unfortunately, Acrobat stops rendering after encountering errors such as these and makes no attempt to explain what's wrong.
The text was updated successfully, but these errors were encountered: