https://github.com/jromero132/pdf-merger
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.
https://github.com/jromero132/pdf-merger
aspect-ratio command-line-tool content-center cross-platform custom-page directory-recursive document-management document-processing file-conversion file-organization image-processing image-to-pdf multi-format-support open-source pdf-merger pdf-tools productivity-tool python python-utility python3
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/jromero132/pdf-merger
- Owner: jromero132
- License: mit
- Created: 2025-04-01T01:06:28.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-04-02T13:51:36.000Z (about 2 months ago)
- Last Synced: 2025-04-02T14:39:11.265Z (about 2 months ago)
- Topics: aspect-ratio, command-line-tool, content-center, cross-platform, custom-page, directory-recursive, document-management, document-processing, file-conversion, file-organization, image-processing, image-to-pdf, multi-format-support, open-source, pdf-merger, pdf-tools, productivity-tool, python, python-utility, python3
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
Awesome Lists containing this project
README
# PDF and Image Merger
[]( "Buy Me a Coffee - jromero132")
[]( "Go to Python homepage")

---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:
```bash
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! 🚀