Skip to content

alibektas/pdf-merger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

PDF Merger

A simple Python script to merge two PDF files into one.

Features

  • Merge two PDF files in sequential order
  • Custom output path or automatic naming with timestamp
  • Validates input files before processing
  • Clear error messages and progress feedback
  • Saves to Desktop by default when no output path is specified

Installation

  1. Clone or download this repository
  2. Install the required dependencies:
pip3 install -r requirements.txt

Or install PyPDF2 directly:

pip3 install PyPDF2

Usage

Basic Syntax

python3 ./src/main.py <PDF1> <PDF2> [--out OUTPUT_PATH]

Examples

Merge with custom output path:

python3 ./src/main.py document1.pdf document2.pdf --out merged.pdf

Merge with automatic naming (saves to Desktop):

python3 ./src/main.py document1.pdf document2.pdf

This creates a file named document1_document2_YYYYMMDD_HHMMSS.pdf on your Desktop.

Using short option flag:

python3 ./src/main.py report.pdf appendix.pdf -o final_report.pdf

Arguments

  • pdf1 - Path to the first PDF file (required)
  • pdf2 - Path to the second PDF file (required)
  • --out, -o - Output path for the merged PDF (optional)

Output Behavior

  • With --out flag: Saves to the specified path
  • Without --out flag: Saves to Desktop with format {PDF1_name}_{PDF2_name}_{timestamp}.pdf
  • The script creates output directories if they don't exist

Error Handling

The script will exit with an error message if:

  • Input PDF files don't exist
  • Files cannot be read or merged
  • Write permissions are insufficient

Requirements

  • Python 3.x
  • PyPDF2

License

This project is open source and available for use.

About

young and dumb merger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages