-
-
Save matandobr/d26d5b6e623531e31306daf2367b5d90 to your computer and use it in GitHub Desktop.
A Python script for merging PDF files together into a single PDF.
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
""" | |
Author: Eric J. Ma | |
Updated: Matan Dobrushin | |
Purpose: Merge all PDFs in the current directory together. | |
Install: pip install PyPDF2==3.0.1 | |
""" | |
import os | |
from PyPDF2 import PdfReader, PdfMerger | |
files_dir = os.getcwd() | |
# Add in main text file. | |
pdfs = [f for f in os.listdir(files_dir) if 'pdf' in f.lower()] | |
# Merge the files | |
merger = PdfMerger() | |
for f in pdfs: | |
merger.append(PdfReader(f), 'rb') | |
merger.write('merged.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment