Skip to content
Discussion options

You must be logged in to vote

The functions copy()/deepcopy() of Python module copy are for pure Python objecs only. Most PyMuPDF objects are far more than that: they have a companion or "shadow" objects within the base library MuPDF.
Therefore these functions cannot be used for what you want.

But there is an easy way to make memory copies of the current state of the document like this:

pdfdata = doc.tobytes(<save options>)
temp = fitz.open("pdf", pdfdata)

The document temp is a full copy of doc. "Save options" means parameters you would also use when saving the document, like garbage, deflate etc.

That temporary document can be saved to disk like normal whenever deemed required.

You can create several temp objects fr…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@4lexRed
Comment options

Comment options

You must be logged in to vote
1 reply
@4lexRed
Comment options

Answer selected by 4lexRed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants