Combine pdf files in PyPDF2 using Python

 This is the quick code for combining pdf files to one single file.


import PyPDF2 as PDF

import glob


allPdfFiles = glob.glob("*.pdf")

merger = PDF.PdfFileMerger(strict=False)


for filename in allPdfFiles:

    merger.append(PDF.PdfFileReader(filename, strict=False))


merger.write("merged_full.pdf")

Comments