[reportlab-users] [PyPDF] I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm)

KLEIN Stéphane stephane at harobed.org
Thu Mar 26 11:51:02 EDT 2009


Hi,

To summarize, with PyPDF package, I would like merge two A4 PDF documents
in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm).

First, I merge two PDF pages with this code :


::


outputStream = file("output.pdf", "w")
output = PdfFileWriter()

background_pages = PdfFileReader(file("background.pdf", "rb"))
foreground_pages = PdfFileReader(file("foreground.pdf", "rb"))

bg_page0 = background_pages.getPage(0)
fg_page0 = foreground_pages.getPage(0)

bg_page0.mergePage( fg_page0 )

output.addPage(page0)

output.write(outputStream)
outputStream.close()

This works greatly.

Background and foreground PDF documents size are A4 (paper size).


>From this point, I would like :


1. create an empty page with this paper size : A4 width + 10 mm, A4
height + 10 mm
2. merge and center background page in current page (page create at step
1)
3. merge and center foreground page

I don't know :

* how to change page size ?
* how to merge and center page ?

I search this informations in PyPDF API and on google... I found nothing.

Thanks for your help,
Stephane



More information about the reportlab-users mailing list