Skip to content

A Python utility for merging multiple PDFs and images into a single PDF file. This tool maintains aspect ratios, centers content on custom-sized pages (default A4), and supports recursive directory processing. Perfect for organizing documents and creating cohesive PDF compilations.

License

Notifications You must be signed in to change notification settings

jromero132/pdf-merger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF and Image Merger

Buy Me a Coffee Made with Python Last commit

This project provides a Python script to merge all PDF files and images in a directory into a single PDF file. PDFs and images are centered on custom-page-sized pages (defaults to A4) while maintaining their aspect ratio.

Features

  • Merge multiple PDF files into a single PDF
  • Convert and add images (BMP, GIF, JPEG, JPG, PNG, TIF, TIFF, WEBP) to the merged PDF
  • Center images on custom-page-sized pages (defaults to A4) while maintaining aspect ratio
  • Recursively process files in directories

Requirements

  • Python 3.6+
  • Dependencies listed in requirements.txt

Installation

  1. Clone this repository:

    git clone https://github.com/jromero132/pdf-merger.git
    cd pdf-merger
    pip install -r requirements.txt```
    

Usage

Run the script from the command line, providing the paths to the files or directories you want to merge:
python main.py /path/to/file1.pdf /path/to/image_directory /path/to/file2.jpg

The script will create a merged PDF file named output.pdf in the current directory.

Supported File Types

  • PDF files (*.pdf)
  • Images: BMP, GIF, JPEG, JPG, PNG, TIF, TIFF, WEBP

How It Works

  1. The script iterates through all provided paths.
  2. For each path:
    • If it's a file, it processes the file.
    • If it's a directory, it recursively processes all files in the directory.
  3. PDF files are directly inserted into the output PDF.
  4. Images are converted to PDF pages:
    • Each image is centered on an custom-page-sized page (defaults to A4).
    • The aspect ratio of the image is maintained.
  5. All processed pages are combined into a single output PDF file.

Support

If you encounter any problems or have any questions, please open an issue in the GitHub repository.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is licensed under the terms of the license file included in this repository.

Happy Coding! 🚀

About

A Python utility for merging multiple PDFs and images into a single PDF file. This tool maintains aspect ratios, centers content on custom-sized pages (default A4), and supports recursive directory processing. Perfect for organizing documents and creating cohesive PDF compilations.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Languages