Closed theottm closed 5 months ago
merge_page is overlapping (Z order). You need to first rescale and move the pages to put then next to each others on a blank page
at first site, you should find some ideas here: https://github.com/py-pdf/pypdf/discussions/1687#discussioncomment-5218716
Great, thank you for the hint!
So this solves it:
import pypdf
import sys
input_filename = sys.argv[-2]
input_pdf = pypdf.PdfReader(input_filename)
output_filename = sys.argv[-1]
output_pdf = pypdf.PdfWriter()
output_pdf.add_page(input_pdf.pages[0])
monopage = output_pdf.pages[0]
insertion_point = monopage.mediabox.height
for page_number in range(1, len(input_pdf.pages)):
print(page_number)
page = input_pdf.pages[page_number]
monopage.merge_translated_page(page, 0, - insertion_point, expand=True)
insertion_point += page.mediabox.height
output_pdf.write(output_filename)
Hi!
I'm trying to stack multiple pages vertically on top one other on a single page. I use the
over=False
option but only the first page appears.Environment
Code + PDF
This is a minimal, complete example that shows the issue:
Then run:
in.pdf