Created
April 19, 2023 09:46
-
-
Save luanvuhlu/b8d43c7d5d4aa0d3f437bf622a695b63 to your computer and use it in GitHub Desktop.
merge all pdf files in a folder https://stackoverflow.com/a/47356404
This file contains hidden or 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
pip install PyPDF2 |
This file contains hidden or 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
import os | |
from PyPDF2 import PdfMerger | |
x = [a for a in os.listdir() if a.endswith(".pdf")] | |
merger = PdfMerger() | |
for pdf in x: | |
merger.append(open(pdf, 'rb')) | |
with open("result.pdf", "wb") as fout: | |
merger.write(fout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment