py-pdf / pypdf

A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files
https://pypdf.readthedocs.io/en/latest/
Other
8.43k stars 1.42k forks source link

Merging pages #109

Closed roberto-arista closed 2 years ago

roberto-arista commented 10 years ago

Hi! I am trying to understand if some specific tasks are possible with this module. I want to realize a script able to produce an imposed pdf from a single page pdf (like Adobe InDesign Print Booklet function).

domanda_github-01

What I need to understand is:

Thanks!

mstamy2 commented 10 years ago

Short answer is yes - you can do all these things with PyPDF2. In the Sample_Code folder, there is a 2_up.py script which demonstrates how to produce imposed PDFs by enlarging the mediaBox and merging a translated page. Hopefully that can help you!

roberto-arista commented 10 years ago

I will try starting from that sample. Thanks for your reply!

roberto-arista commented 10 years ago

Hi!

I tried the mergeTranslatedPage() method.

Everything works but:

If you want, I can pull the different pdf files to the PDF_Samples folder.

mozbugbox commented 10 years ago

I saw this happened too. It turns out that the mediaBox is not the only box need to be set after a merge. There are also cropBox, bleedBox, trimBox and artBox. every single of this box also affect the merged page in some way.

PageObject._mergePage() only set a larger mediaBox. If there are cropBox in the 1st page, only the 1st page will be displayed after the merge.

Shall the _mergePage() set all the other boxes according if any of the boxes exists in the 1st page?

mstamy2 commented 10 years ago

The scaling in _mergePage() is similar to that in the scale() method - they both only change the mediaBox. I think it's reasonable to say that other existing page boxes should scale to the same factor of the mediaBox.

MartinThoma commented 2 years ago

There was no activity on this for a long time, hence I'll close it.

If there is still something to discuss / a new feature you would like to have, please ping me here. Then I'll re-open.