Here's the README and Setup in English:
A simple and easy-to-use desktop application for performing basic operations with PDF files, such as merging, extracting pages, and compressing. Developed in Python with tkinter for the cross-platform user interface and pypdf for PDF processing.
- Merge PDFs: Combine multiple PDF files or specific page ranges from several PDFs into a single document.
- Extract/Crop Pages: Select and save specific pages from a PDF into a new file.
- Compress PDF (Basic): Attempts to reduce the size of a PDF file by applying internal compression (FlateDecode).
- Page Count Display: Shows the total number of pages for each selected PDF.
- Preview: Opens the selected PDF with your operating system's default application for a quick review.
- Intuitive Graphical Interface: Simple and clear user interface built with
tkinter. - Cross-Platform: Compatible with Windows, macOS, and Linux.
Follow these steps to set up and run the application on your system.
Make sure you have Python 3.x installed on your system. You can download it from python.org.
-
Clone or download the repository: If you use Git:
git clone https://github.com/godie/pdf_tools.git cd pdf_tools # For example, cd pdf-tool
Or simply download the pdf_tool.py file and place it in a folder of your choice.
-
Create a virtual environment (recommended): It's good practice to create a virtual environment to manage your project's dependencies.
python -m venv venv
-
Activate the virtual environment:
- On Windows:
.\venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install dependencies: The application requires the
pypdflibrary. Install it usingpip:pip install pypdf
Important! Make sure you have the latest version of
pypdf(v3.0.0 or higher) for the basic compression functionality (compress=True) to work correctly and avoid errors. If you already have it installed, upgrade it:pip install --upgrade pypdf
-
Run the application: Once you have completed the
Setupand activated your virtual environment (if you created one), you can run the application from your terminal:python pdf_tool_app.py
(Make sure
pdf_tool_app.pyis the name of your main file). -
Navigate the interface: The main application window will be divided into three main sections:
-
1. Merge PDFs:
- Click "Select PDFs to Merge" to choose one or more files.
- The list will display the selected files with their page count.
- Double-click on a file in the list to preview it.
- Specify the pages to merge from EACH PDF (e.g.,
1-5, 8, 10-lastorAll). - Click "Merge Selected PDFs" and choose where to save the new PDF.
-
2. Crop/Extract PDF Pages:
- Click "Select PDF to Crop" to choose the source file.
- Use "Preview PDF" to open it.
- Specify the pages to extract (e.g.,
1-5, 8, 10-lastorAll). - Click "Extract Pages" and choose where to save the resulting PDF.
-
3. Compress PDF:
- Click "Select PDF to Compress" to choose the file.
- Use "Preview PDF" to open it.
- Click "Compress PDF" and choose where to save the compressed version. The application will inform you about the size reduction.
-
The compression functionality in this tool is basic and uses pypdf's native capabilities to optimize internal PDF streams.
- Light Compression: It only applies
FlateDecodecompression to objects that are not already compressed. This can help if the original PDF has a lot of uncompressed data (text, simple vector graphics). - No Image Optimization: This tool does not reduce the quality or resolution of embedded images in the PDF. If your PDF is large due to high-resolution images, the size reduction will be limited.
- For Greater Compression: For more aggressive compression (including image resampling, removal of unused fonts, etc.), it is recommended to use external and more powerful tools like Ghostscript (which you would need to install separately and run via command line or integrate into your script) or online PDF compression services.
If you wish to improve this tool, contributions are welcome! You can open an issue to report bugs or suggest new features, or submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for more details.
