You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Retrieve all the versions of a PDF when saved incrementally #3092
Currently, I'm utilizing pdfresurrect, a C tool/library designed to "extract older 'hidden' versions of a PDF from the current PDF."
While my larger application is built using PyMuPDF, I have to call the compiled C code through Python for version retrieval, which is not an ideal way of building applications.
I propose that enhancing the capability to retrieve all PDF version files directly within PyMuPDF would be beneficial.
pattern=re.compile(b'[^t]xref.*?EOF', flags=re.M+re.S)
# `inc_nb` means the number of incremental update contained in the binarymatches=list(pattern.finditer(doc.data))
inc_nb=len(matches)
ifnotinc_nb>1:
returnresult# here we loop to separate each incremental update in# the binary to retrieve each version of the file# We don't take into account the current versionforsubinmatches[:-1]:
stream=doc.data[:sub.span()[1]] # binary code of a versionifnotstream:
continueprevious=Doc(stream).as_fitz() # is one of the previous version of the file
This feature would have to be implemented by our base library MuPDF to make any sense.
Currently, you can find out the number of versions of a PDF: doc.version_count only.
Please talk to the MuPDF colleagues on e.g. their Dicscord channel about options they may see.
Activity
cipri-tom commentedon Jan 24, 2024
Here's how I do it:
JorjMcKie commentedon Jan 25, 2024
This feature would have to be implemented by our base library MuPDF to make any sense.
Currently, you can find out the number of versions of a PDF:
doc.version_countonly.Please talk to the MuPDF colleagues on e.g. their Dicscord channel about options they may see.