Insert_pdf different result on same file #4365
-
I was testing the new annots and widgets options in insert_pdf, but got different result when operating on the same file twice. Following are the codes:
document_1 and original_1 is the same while document_2 is different. I have a work around that I can do |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are right, support for widget-copy modifies the source file unintendedly. I will open a bug issue for this. Apart from that, you shouldn't be doing things the way you did:
Here is a version that does things correctly. import pymupdf
doc_pdf = pymupdf.open("test_annotation.pdf")
print("Page number", doc_pdf.page_count)
stacked_file = pymupdf.open()
stacked_file.insert_pdf(doc_pdf)
stacked_file.ez_save("document_1.pdf")
doc_pdf = pymupdf.open(doc_pdf.name) # <== this should not be necessary
stacked_file_2 = pymupdf.open()
stacked_file_2.insert_pdf(doc_pdf)
stacked_file_2.ez_save("document_2.pdf")
|
Beta Was this translation helpful? Give feedback.
You are right, support for widget-copy modifies the source file unintendedly. I will open a bug issue for this.
Apart from that, you shouldn't be doing things the way you did:
pymupdf.Documents
from memory every single time.Here is a version that does things correctly.