0

I am tying to merge 1500-1600 PDFs. Thanks to below link, I got a code to merge PDFs in python.

Merge PDF files

However, it is resulting in a empty file, probably because there are digital signatures in the PDFs I am combining.

Can someone suggest a way to combine these files having digital signatures? I do not mind losing digital signature in the output file. (It is also ok, if there is a way to remove digital signatures from the source files and then combine them)

Code:

import os
from PyPDF2 import PdfFileMerger

os.chdir("C:\\test")

x = [a for a in os.listdir() if a.endswith(".pdf")]

merger = PdfFileMerger()

for pdf in x:
    pdfobject = open(pdf, 'rb')
    merger.append(pdfobject)
    pdfobject.close()
    
merger.write("result.pdf")
merger.close()
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958

0 Answers0