-
As per the docs, I do not have any examples of files that can not save incrementally. Does anyone have an example PDF that I can use to test my error-handling logic? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
That is easy: just make a 1-page empty file, edit it with some text editor and remove the last2 or 3 lines, then save. |
Beta Was this translation helpful? Give feedback.
-
Here is how: import pymupdf
doc=pymupdf.open()
page=doc.new_page()
doc.save("kaputt.pdf") Gives you this:
Delete the last 3 lines and save. Then open again and check whether we can save incrementally: doc=pymupdf.open("kaputt.pdf")
print(pymupdf.TOOLS.mupdf_warnings())
format error: cannot find startxref
trying to repair broken xref
repairing PDF document
doc.is_repaired
True
doc.can_save_incrementally()
0 |
Beta Was this translation helpful? Give feedback.
Here is how:
Gives you this:
Delete the last 3 lines and save. Then open again and check whether we can save incrementally: