Created
August 8, 2023 23:52
-
-
Save sueszli/68fd380b01e4b52852d9ac0b3fa5b961 to your computer and use it in GitHub Desktop.
merge pdf files together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyPDF2 import PdfFileMerger | |
import os | |
inputPath = "./extractedPages" | |
total = len(os.listdir(inputPath)) | |
count = 1 | |
merger = PdfFileMerger() | |
for pdf in os.listdir(inputPath): | |
merger.append(open(inputPath + "/" + pdf, "rb")) | |
print("merged [" + str(count) + "/" + str(total) + "] ...", pdf) | |
count += 1 | |
with open("merged.pdf", "wb") as out: | |
merger.write(out) | |
print("Merged all pages") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment