Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In pdfpdf 5.3.1 duplicated pages overwrites the original page's data it is duplicating. #3171

Open
kamranbadirov opened this issue Mar 7, 2025 · 1 comment
Labels
on-hold PR requests that need clarification before they can be merged.A comment must give details

Comments

@kamranbadirov
Copy link

kamranbadirov commented Mar 7, 2025

I was duplicating a page from reader with copy.deepcopy and adding it to writer with writer.add_page. The duplicated page overwrites the page it is duplicating.
For example, if Page1 has a field Name filled with value John, and you duplicate Page1 and add new values , e.g. Page2 is added "Marvin", Page3 "is added "Adam", then in the generated pdf all the Name fields will be contain Adam - the last duplicated page's value.

Environment

$ python -m platform
macOS-14.7.4-arm64-arm-64bit

$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==5.3.1 crypt_provider=('cryptography', '40.0.1'), PIL=9.5.0

Code + PDF

This is a minimal, complete example that shows the issue:

writer_kwargs: WriterKwargs = {'flags': FieldFlag(unlock_flag)}
reader = PdfReader(filename)
writer: PdfWriter = PdfWriter(clone_from=reader)
new_page_fields = data[i]
current_page = writer.add_page(deepcopy(reader.pages[EMPLOYMENT_PAGE_INDEX]))
new_page_writer_kwargs = writer_kwargs.copy()
update_pdf_writer_page(writer, current_page, new_page_fields, new_page_writer_kwargs)

file.pdf

@stefan6419846
Copy link
Collaborator

Thanks for the report. Unfortunately, your issue lacks some details:

  • The "minimal, complete example" has quite some undefined variables and functions. Please make sure that it can be executed as-is.
  • Is this issue new to version 5.3.1 or why do you explicitly mention it in the title?

Apart from this, it has not been directly clear to me that this issue refers to filling a form as this has not been mentioned in the title or the description.

@stefan6419846 stefan6419846 added the on-hold PR requests that need clarification before they can be merged.A comment must give details label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-hold PR requests that need clarification before they can be merged.A comment must give details
Projects
None yet
Development

No branches or pull requests

2 participants