Skip to content

Instantly share code, notes, and snippets.

@lordjabez
Created October 22, 2025 17:38
Show Gist options
  • Save lordjabez/c1fb8ffc221fff703fe9354b428dad66 to your computer and use it in GitHub Desktop.
Save lordjabez/c1fb8ffc221fff703fe9354b428dad66 to your computer and use it in GitHub Desktop.
Merge a set of PDFs
#!/usr/bin/env python3
import sys
import pypdf
output_filename = sys.argv[1]
input_filenames = sys.argv[2:]
merger = pypdf.PdfWriter()
for input_filename in input_filenames:
merger.append(input_filename)
with open(output_filename, 'wb') as output_file:
merger.write(output_file)
print(f'Successfully merged PDFs into "{output_filename}"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment