Skip to content

How to Insert Pages from other PDFs

Jorj X. McKie edited this page Jan 17, 2019 · 2 revisions

Document method insertPDF can be used to join or merge PDF files. The following example takes a list of PDF files and creates a new PDF with the last page of every input rotated by 90 degrees.

>>> import fitz
>>> flist=["1.pdf","2.pdf","3.pdf","4.pdf",]
>>> doc=fitz.open()
>>> for f in flist:
	x=fitz.open(f)
	doc.insertPDF(x, from_page=len(x)-1, to_page=len(x)-1, rotate=90)
>>> doc.save("out.pdf", deflate=True, garbage=3)
Clone this wiki locally