Skip to content

Commit 2af25e4

Browse files
author
ciwga
committed
Update README.md: Add CLI usage examples and new features
1 parent 0053d3c commit 2af25e4

File tree

1 file changed

+62
-7
lines changed

1 file changed

+62
-7
lines changed

README.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p align="center">
33
<img src="assets/pdftoolkit.png" alt="PDF Toolkit" width="142"/>
44
</p>
5-
PDF Toolkit is a Python application that provides a graphical user interface (GUI) for performing various operations on PDF files, such as editing metadata, extracting pages, and extracting images. The application is built using `tkinter` for the GUI and `PyPDF2` for PDF operations.
5+
PDF Toolkit is a Python application that provides both a graphical user interface (GUI) and a command-line interface (CLI) for performing various operations on PDF files. These operations include editing metadata, extracting pages and images, merging PDFs, and creating PDFs from images.
66

77
## Features
88

@@ -11,31 +11,86 @@ PDF Toolkit is a Python application that provides a graphical user interface (GU
1111
- **Save and Load Metadata**: Save metadata to a JSON file and load metadata from a JSON file.
1212
- **Page Operations**: Extract specific pages from a PDF file and save them as a new PDF.
1313
- **Image Operations**: Extract images from a PDF file and save them to a specified directory.
14+
- **PDF Merging**: Combine multiple PDF files into a single document.
15+
- **Image to PDF Conversion**: Convert image files to PDF with customizable page settings.
1416
- **Drag and Drop**: Drag and drop PDF files directly into the application for easy loading.
1517
- **Window Centering**: The application window opens centered on the screen.
18+
- **CLI Interface**: Use all features via command-line for batch operations.
1619

1720
## Requirements
1821

1922
- Python 3.7+
2023
- `PyPDF2` library
2124
- `tkinterdnd2` library
25+
- `pillow` library
2226

2327
You can install the required library using the following command:
2428

25-
```sh
29+
```
2630
pip install -r requirements.txt
2731
```
2832

2933
## Usage
30-
**Running the Application**
34+
### **Running the Application (GUI)**
3135

32-
To run the application, execute the following command:
33-
```bash
36+
To launch the graphical user interface, execute the following command:
37+
```
3438
python pdftoolkit.py
3539
```
3640

37-
### User Interface
41+
### **Command-Line Interface (CLI)**
42+
43+
The PDF Toolkit CLI supports various operations on PDF files. Below are some usage examples:
44+
#### Read PDF Metadata
45+
```
46+
pdftoolkit_cli.py read example.pdf
47+
```
48+
This command reads the metadata of the specified PDF file.
49+
#### Validate a PDF File
50+
```
51+
pdftoolkit_cli.py validate example.pdf
52+
```
53+
This command checks whether the provided PDF file is valid.
54+
#### Extract Specific Pages
55+
```
56+
pdftoolkit_cli.py extract-pages example.pdf "1-3,5" extracted.pdf
57+
```
58+
Extracts pages 1-3 and page 5 from the PDF and saves them to a new file.
59+
#### Merge Multiple PDFs
60+
```
61+
pdftoolkit_cli.py merge file1.pdf file2.pdf merged.pdf
62+
```
63+
Merges the listed PDF files into a single PDF.
64+
#### Create a PDF from Images
65+
You can specify margins either individually or as a sequence of four values.
66+
67+
**Using Individual Margin Arguments:**
68+
```
69+
pdftoolkit_cli.py create-from-images img1.jpg img2.png output.pdf \
70+
--margin-left 0 --margin-right 0 --margin-top 0 --margin-bottom 0 \
71+
--page-size A4 --orientation portrait --scaling "scale to fit"
72+
```
73+
74+
**Using Sequential Margin Values:**
75+
```
76+
pdftoolkit_cli.py create-from-images img1.jpg img2.png output.pdf \
77+
--margins 0 0 0 0 --page-size A4 --orientation portrait --scaling 1
78+
```
79+
Default margin values (left, right, top, bottom) are 10.
80+
81+
The ```--scaling``` option accepts both text values (e.g., "scale to fit", "stretch to fit", "actual size", "stretch to fill") and integer values (1-4) mapping to these options.
82+
83+
84+
## User Interface
3885

3986
The following image shows the graphical user interface of the PDF Toolkit:
4087

41-
![PDF Toolkit GUI](assets/gui.png)
88+
<div align="center">
89+
<table>
90+
<tr>
91+
<td><img src="assets/gui.png" width="900" alt="PDF Operations Tab"></td>
92+
<td><img src="assets/gui_merger_tab.png" width="900" alt=" PDF Merger Tab"></td>
93+
<td><img src="assets/gui_image_to_pdf_tab.png" width="900" alt="Image to PDF Tab"></td>
94+
</tr>
95+
</table>
96+
</div>

0 commit comments

Comments
 (0)