Skip to content

It seems that merge_page corrupts the file, but I can't determine if it actually corrupts the file. #2683

Closed Answered by stefan6419846
ssjkamei asked this question in Q&A
Discussion options

You must be logged in to vote

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")

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by stefan6419846
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants