It seems that merge_page corrupts the file, but I can't determine if it actually corrupts the file. #2683
-
The files were merged using merge_page.
The following is a simple code. from pypdf import PdfReader, PdfWriter
with open("merge_base.pdf", "rb") as data_f:
merge_base = PdfReader(data_f)
with open("add_file.pdf", "rb") as data_f:
add_file = PdfReader(data_f)
pdf_file_writer = PdfWriter()
for i in range(0, 1):
pdf_file_writer.add_page(merge_base.pages[i])
for i in range(0, 1):
pdf_file_writer.pages[i].merge_page(
add_file.pages[i])
pdf_file_writer.write("JoinedPDF.pdf") |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Which version of pypdf are you using? Did you try with the latest release? I just tested it with (nearly) the latest head and rendering works correct with some minified code: from pypdf import PdfReader, PdfWriter
merge_base = PdfReader("merge_base.pdf")
add_file = PdfReader("add_file.pdf")
pdf_file_writer = PdfWriter()
for page in merge_base.pages:
pdf_file_writer.add_page(page)
for i in range(len(pdf_file_writer.pages)):
pdf_file_writer.pages[i].merge_page(add_file.pages[i])
pdf_file_writer.write("JoinedPDF.pdf") |
Beta Was this translation helpful? Give feedback.
-
I was running on When upgrading from I will register this matter for another discussion. |
Beta Was this translation helpful? Give feedback.
Which version of pypdf are you using? Did you try with the latest release? I just tested it with (nearly) the latest head and rendering works correct with some minified code: