Last active
April 18, 2023 20:46
-
-
Save napsternxg/326ee4ba9cd9ecb949e79cc9a71401e6 to your computer and use it in GitHub Desktop.
Merge PDFs
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
""" | |
pip install pypdf | |
""" | |
from pypdf import PdfWriter | |
def main(args): | |
merger = PdfWriter() | |
file_paths = args.input_files | |
for pdf in file_paths: | |
merger.append(pdf) | |
merger.write(args.output_file) | |
merger.close() | |
if __name__ == "__main__": | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("output_file") | |
parser.add_argument("--input_files", nargs="+") | |
args = parser.parse_args() | |
main(args) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment