🔐 PDF Merger App
This application provides a robust, web-based graphical user interface (GUI) for merging multiple PDF files into a single document with advanced features. It is built using Python and the Streamlit framework.
✨ Key Features
- Easy File Upload: Upload multiple PDF files directly through the web interface.
- Custom Merge Order (Drag-and-Drop): Use the integrated sorter to manually rearrange the PDF files to define the exact merging sequence.
- Password Protection Removal: If a source PDF is password-protected, the app allows you to input the password, decrypt the file during processing, and merge its contents. The final merged output file will be unencrypted.
- Reliable Merging: Combines all successfully processed PDFs into one …
🔐 PDF Merger App
This application provides a robust, web-based graphical user interface (GUI) for merging multiple PDF files into a single document with advanced features. It is built using Python and the Streamlit framework.
✨ Key Features
- Easy File Upload: Upload multiple PDF files directly through the web interface.
- Custom Merge Order (Drag-and-Drop): Use the integrated sorter to manually rearrange the PDF files to define the exact merging sequence.
- Password Protection Removal: If a source PDF is password-protected, the app allows you to input the password, decrypt the file during processing, and merge its contents. The final merged output file will be unencrypted.
- Reliable Merging: Combines all successfully processed PDFs into one consolidated, clean file.
- Downloadable Output: Provides a direct button to download the merged PDF file.
🚀 Installation and Setup
Follow these steps to set up and run the application locally on your machine.
1. Prerequisites
You must have Python 3.8+ installed on your system. It is highly recommended to use a virtual environment to manage dependencies.
2. Virtual Environment Setup
Activate your virtual environment (if you haven’t already):
macOS/Linux:
python3 -m venv venv
source venv/bin/activate
Windows:
python -m venv venv
venv\Scripts\activate
3. Install Dependencies
Install all necessary Python libraries: Streamlit (for the GUI), PyPDF2 (for PDF manipulation), and streamlit-sortables (for drag-and-drop).
pip install streamlit PyPDF2 streamlit-sortables
or
pip install -r requirements.txt
💻 Usage
1. Save the Code
Save the Streamlit application code (the final version) into a file named pdf_merger_STVPW.py.
2. Run the App
With your virtual environment activated, run the Streamlit application from your terminal:
Bash
streamlit run pdf_merger_ST_VPW.py
3. Application Workflow
- Upload Files: Click "1. Choose PDF files" to select your documents.
- Input Passwords (Optional): If any file is protected, the app will generate an input field under "2. Password Input." Enter the correct password to allow the file to be decrypted and merged.
- Reorder Files: Under "3. Drag-and-Drop to Reorder," click and drag the file names to arrange them in the desired merge sequence (top file comes first).
- Merge: Click the "✨ Execute Merge" button.
- Download: Once successful, click "⬇️ Download Merged PDF."
⚠️ Troubleshooting a Common Error
If you see a ModuleNotFoundError despite having installed the libraries:
ModuleNotFoundError: No module named '...'
This means you are running the application using a Python interpreter outside of your activated virtual environment.
Solution: Ensure you execute the source venv/bin/activate (or Windows equivalent) command before running streamlit run .... Your terminal prompt must display (venv) to confirm activation.
📦 Project Details
Libraries Used:
streamlit: For creating the interactive web GUI.PyPDF2: For reading, decrypting, and merging the PDF files.streamlit-sortables: For enabling the user-friendly drag-and-drop functionality.io.BytesIO: For efficiently handling files in memory without saving them to the disk.