Skip to content

Example needed of PDF that will not work with incremental save #3640

Answered by JorjMcKie
cmyers009 asked this question in Q&A
Discussion options

You must be logged in to vote

Here is how:

import pymupdf
doc=pymupdf.open()
page=doc.new_page()
doc.save("kaputt.pdf")

Gives you this:

%PDF-1.7
%µ¶

1 0 obj
<</Type/Catalog/Pages 2 0 R>>
endobj

2 0 obj
<</Type/Pages/Count 1/Kids[4 0 R]>>
endobj

3 0 obj
<<>>
endobj

4 0 obj
<</Type/Page/MediaBox[0 0 595 842]/Rotate 0/Resources 3 0 R/Parent 2 0 R>>
endobj

xref
0 5
0000000000 00001 f 
0000000016 00000 n 
0000000062 00000 n 
0000000114 00000 n 
0000000135 00000 n 

trailer
<</Size 5/Root 1 0 R/ID[<2D1361C29C7F75306959677FC2A6C29A><0294DFE0C1FCB0F899F051FFB2CCF2F9>]>>
startxref
226
%%EOF

Delete the last 3 lines and save. Then open again and check whether we can save incrementally:

doc=pymupdf.open("kaputt.pdf")
print(p…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JorjMcKie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants