Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/musatahawar/pdf-merger
This is a Python script that uses the PyPDF2 library to merge multiple PDF files into a single PDF document. The script allows you to specify the order in which the PDFs are merged and provides robust error handling.
https://github.com/musatahawar/pdf-merger
pytho python-3 python3
Last synced: 5 days ago
JSON representation
This is a Python script that uses the PyPDF2 library to merge multiple PDF files into a single PDF document. The script allows you to specify the order in which the PDFs are merged and provides robust error handling.
- Host: GitHub
- URL: https://github.com/musatahawar/pdf-merger
- Owner: MusaTahawar
- License: mit
- Created: 2023-11-02T07:08:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-02T07:13:17.000Z (about 1 year ago)
- Last Synced: 2024-11-09T17:19:03.612Z (2 months ago)
- Topics: pytho, python-3, python3
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advanced PDF Merging Script
This is a Python script that uses the `PyPDF2` library to merge multiple PDF files into a single PDF document. The script allows you to specify the order in which the PDFs are merged and provides robust error handling.
## Getting Started
To run this script, you need to have Python and the `PyPDF2` library installed on your system.
1. **Clone the repository** to your local machine:
```shell
git clone https://github.com/yourusername/advanced-pdf-merger.git
cd advanced-pdf-merger
```2. **Run the script**:
```shell
python merge_pdfs.py
```The script will merge the PDF files as specified and save the merged PDF as "merged.pdf" by default.
## Features
- **PDF Merging:** Merge multiple PDF files into a single PDF document.
- **Custom Merge Order:** Specify the order in which the PDFs are merged by providing a custom merge order.
- **Robust Error Handling:** The script includes error handling to gracefully handle any issues that may arise during the merging process.## Usage
### Basic Usage
To merge PDFs in the order they appear in the `pdf_files` list:
```python
# List of PDF files to merge
pdf_files = ["file1.pdf", "file2.pdf", "file3.pdf"]# Output filename for the merged PDF
output_pdf = "merged.pdf"merge_pdfs(pdf_files, output_pdf)
Custom Merge Order
To specify a custom order for merging the PDFs, provide a list of indices in the merge_order parameter:python
Copy code
# Specify the order of merging (e.g., merge in the order [1, 2, 0])
merge_order = [1, 2, 0]merge_pdfs(pdf_files, output_pdf, merge_order)