Skip to content Skip to sidebar Skip to footer

Pypdf2 Complete Clone Of File

I am trying to copy a PDF in its entirety using PyPDF2, the following code copies the content but not the outline of the pdf. here is a sample pdf and use the code as follows pytho

Solution 1:

PdfFileWriter does have a number of methods for copying an entire file: appendPagesFromReader, cloneReaderDocumentRoot, and cloneDocumentFromReader.

However, I can't get them to work properly either. ;-) You might have better luck.

Solution 2:

probably not a 100% exact replica, but...

for i in range(input_pdf.getNumPages()): output_pdf.addPage(input_pdf.getPage(i))

Post a Comment for "Pypdf2 Complete Clone Of File"