Skip to content

Instantly share code, notes, and snippets.

@Syncrossus
Last active October 22, 2021 13:43
Show Gist options
  • Save Syncrossus/248a66ad98008a7c3c3b731686cfcb80 to your computer and use it in GitHub Desktop.
Save Syncrossus/248a66ad98008a7c3c3b731686cfcb80 to your computer and use it in GitHub Desktop.
A script for merging PDF files which doesn't halt with a PdfReadError. No longer works with some newer PDFs. Based on this thread: https://github.com/mstamy2/PyPDF2/issues/244
import PyPDF2 as PDF
import sys
def pdf_cat(allPdfFiles):
merger = PDF.PdfFileMerger(strict=False)
for filename in allPdfFiles:
merger.append(PDF.PdfFileReader(filename, strict=False))
merger.write("merged_full.pdf")
if __name__ == '__main__':
pdf_cat(sys.argv[1:])
@Syncrossus
Copy link
Author

Syncrossus commented Sep 18, 2019

None of this code is mine. It is pieced together from posts on this issue thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment