Skip to content

Insert_pdf different result on same file #4365

Discussion options

You must be logged in to vote

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:

  1. There is absolutely no need to open pymupdf.Documents from memory every single time.
  2. Never do loops like this one:
    for page_num in range(doc_pdf.page_count):
        stacked_file.insert_pdf(doc_pdf, from_page=page_num, to_page=page_num, annots=True, widgets=True)
    This effectively does its best to achieve worst-possible performance! Always use the maximum available page range.

Here is a version that does things correctly.

import pymupdf

doc_pdf = pymupdf.open("test_annotation.pdf")
print("Page number", doc_pdf.page_count

Replies: 1 comment 1 reply

Comment options

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

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