Skip to content

Commit 9dae7c3

Browse files
v0.1.0: PDF-Helper is now an installable package!
1 parent 82e9329 commit 9dae7c3

9 files changed

Lines changed: 570 additions & 288 deletions

File tree

.github/workflows/pypi.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: pypi
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
8+
jobs:
9+
build-and-publish:
10+
name: build and publish
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@master
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: '3.x'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install uv
25+
26+
- name: Build
27+
run: |
28+
uv build
29+
pip install dist/*.whl
30+
echo "PACKAGE_VERSION=$(pip show pdf-helper | grep '^Version: ' | cut -d ' ' -f 2)" >> $GITHUB_ENV
31+
32+
- name: check-version
33+
uses: KyoriPowered/action-regex-match@v3
34+
id: check-version
35+
with:
36+
text: ${{ env.PACKAGE_VERSION }}
37+
regex: '\d+\.\d+\.\d+a\d+'
38+
39+
- name: Publish
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
if: ${{ steps.check-version.outputs.match == '' }} # If didn't match
42+
with:
43+
password: ${{ secrets.PYPI_API_TOKEN }}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023-2025 CodeWriter21
3+
Copyright (c) 2023-2026 CodeWriter21
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
PDF-Helper
22
==========
33

4-
A simple python script that helps with doing simple stuff with PDFs. It is going to
5-
become a simple python package after `main.py` reaches 1000 lines of code.
4+
A simple python package that helps with doing simple stuff with PDFs.
65

76
Features
87
--------
@@ -27,103 +26,118 @@ after adding your contribution.
2726
Usage
2827
-----
2928

30-
### Install requirements
29+
### Installation
3130

32-
+ Install Python for your operating system. Visit [python.org](https://python.org)
31+
You can install PDF-Helper via pip:
3332

34-
+ Clone the repo:
33+
```bash
34+
pip install pdf-helper
35+
36+
# Or use uv to install the tool
37+
uv tool install pdf-helper
38+
```
39+
40+
And run it using the command line:
41+
42+
```bash
43+
pdf-helper <command> [options]
44+
```
45+
46+
Or you can use uvx to run the package without installing it in a specific python environment:
3547

3648
```bash
37-
git clone https://GitHub.com/MPCodeWriter21/PDF-Helper
49+
uvx pdf-helper <command> [options]
3850
```
3951

40-
+ Use pip to install the dependencies:
52+
You can also clone the repository and use `uv run`:
4153

4254
```bash
43-
pip install -r requirements.txt
55+
git clone https://github.com/MPCodeWriter21/PDF-Helper.git
56+
cd PDF-Helper
57+
uv run pdf-helper <command> [options]
4458
```
4559

4660
### Merge PDFs
4761

4862
Merge multiple PDFs into one PDF:
4963

5064
```bash
51-
python3 main.py merge -i <input_file_1> <input_file_2>... <input_file_n> -o <output_file>
65+
pdf-helper merge -i <input_file_1> <input_file_2>... <input_file_n> -o <output_file>
5266

5367
# E.g. Merge PDFs 1, 2 and 3 into a new PDF
54-
python3 main.py merge -i 1.pdf 2.pdf 3.pdf -o new.pdf
68+
pdf-helper merge -i 1.pdf 2.pdf 3.pdf -o new.pdf
5569
```
5670

5771
### Split PDFs
5872

5973
Split a PDF into multiple PDFs, each containing a range of pages:
6074

6175
```bash
62-
python3 main.py split -i <input_file> -o <output_folder> -s <split_point_1>,<split_point_2>
76+
pdf-helper split -i <input_file> -o <output_folder> -s <split_point_1>,<split_point_2>
6377

6478
# E.g. Split a PDF into three PDFs, one with pages 1-10, the second with pages 11-20 and
6579
# the third with pages 21-end
66-
python3 main.py split -i my-pdf.pdf -o my-split-pdfs -s 10,20
80+
pdf-helper split -i my-pdf.pdf -o my-split-pdfs -s 10,20
6781

6882
# E.g. Split a PDF into PDFs each containing one page
69-
python3 main.py split -i my-pdf.pdf -o my-split-pdfs # No need to specify split points
83+
pdf-helper split -i my-pdf.pdf -o my-split-pdfs # No need to specify split points
7084
```
7185

7286
### Export PDF pages as image files
7387

7488
Export PDF pages as image files:
7589

7690
```bash
77-
python3 main.py to-image -i <input_file> -o <output_folder> \
91+
pdf-helper to-image -i <input_file> -o <output_folder> \
7892
-p <page_number_1>,<page_number_2>,...,<page_number_n> -s <scale_factor>
7993

8094
# E.g. Export pages 1, 2, 3 and 6 from a PDF with scale factor 1
81-
python3 main.py to-image -i 1.pdf -o images -p 1-3,6 -s 1
95+
pdf-helper to-image -i 1.pdf -o images -p 1-3,6 -s 1
8296

8397
# E.g. Export all pages from a PDF with scale 2
84-
python3 main.py to-image -i my-pdf.pdf -o my-images
98+
pdf-helper to-image -i my-pdf.pdf -o my-images
8599
```
86100

87101
### Remove pages from a PDF
88102

89103
Remove pages from a PDF:
90104

91105
```bash
92-
python3 main.py remove-pages -i <input_file> -o <output_file> -p <page_number_1>,<page_number_2>,...,<page_number_n>
106+
pdf-helper remove-pages -i <input_file> -o <output_file> -p <page_number_1>,<page_number_2>,...,<page_number_n>
93107

94108
# E.g. Remove pages 1, 2, 3 and 6 from a PDF
95-
python3 main.py remove-pages -i 1.pdf -o new.pdf -p 1-3,6
109+
pdf-helper remove-pages -i 1.pdf -o new.pdf -p 1-3,6
96110
```
97111

98112
### Export text from a PDF
99113

100114
To extract text from a PDF file and export them to text files you can do as follows:
101115

102116
```bash
103-
python3 main.py extract-text -i <input_file> -o <output_file_name>
117+
pdf-helper extract-text -i <input_file> -o <output_file_name>
104118

105119
# E.g. Extract text from a PDF named my-pdf.pdf and save it to my-text.txt
106-
python3 main.py extract-text -i my-pdf.pdf -o my-text.txt
120+
pdf-helper extract-text -i my-pdf.pdf -o my-text.txt
107121
```
108122

109123
### Export one or multiple images as a PDF file
110124

111125
You simply provide the script with your images, and it will create a PDF file with them:
112126

113127
```bash
114-
python3 main.py image-to-pdf -i <image_1> <image_2> <image_3> ... -o <output_file>
128+
pdf-helper image-to-pdf -i <image_1> <image_2> <image_3> ... -o <output_file>
115129

116130
# E.g. Take 1.png, 2.jpg, and 3.png and create a PDF named 123.pdf and override
117131
# if already exists
118-
python3 main.py image-to-pdf -i 1.png 2.jpg 3.png -o 123.pdf -f
132+
pdf-helper image-to-pdf -i 1.png 2.jpg 3.png -o 123.pdf -f
119133
```
120134

121135
About
122136
-----
123137

124138
Author: [CodeWriter21](https://github.com/MPCodeWriter21)
125139

126-
GitHub: [MPCodeWriter21/PDF-To-Image](https://github.com/MPCodeWriter21/PDF-To-Image)
140+
GitHub: [MPCodeWriter21/PDF-Helper](https://github.com/MPCodeWriter21/PDF-Helper)
127141

128142
Donations
129143
---------

pyproject.toml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
[project]
22
name = "PDF-Helper"
3+
version = "0.1.0"
34
authors = [
45
{name = "CodeWriter21(Mehrad Pooryoussof)", email = "CodeWriter21@gmail.com"}
56
]
67
description = "A simple python script that helps with doing simple stuff with PDFs."
78
readme = {file = "README.md", content-type = "text/markdown"}
8-
requires-python = ">=3.8"
9-
license = {text = "MIT"}
10-
11-
[tool.pylint.messages_control]
12-
max-line-length = 88
13-
14-
disable = [
15-
"too-few-public-methods",
16-
"too-many-arguments",
17-
"protected-access",
18-
"too-many-locals",
19-
"fixme",
9+
license = {text = "MIT", file = "LICENSE"}
10+
requires-python = ">=3.9"
11+
dependencies = [
12+
"log21>=3.0.0",
13+
"pypdfium2>=4.30.0",
14+
"Pillow>=11.0.0"
2015
]
2116

22-
[tool.pylint.design]
23-
max-returns = 8
17+
[project.scripts]
18+
pdf-helper = "pdf_helper:__main__.main"
19+
20+
[build-system]
21+
requires = ["uv_build>=0.8.22,<0.9.0"]
22+
build-backend = "uv_build"
2423

2524
[tool.yapf]
2625
column_limit = 88
@@ -42,8 +41,8 @@ wrap-descriptions = 88
4241
[tool.ruff]
4342
show-fixes = true
4443
exclude = ["migrations"]
45-
target-version = "py38"
44+
target-version = "py39"
4645
line-length = 88
4746

4847
[tool.ruff.lint]
49-
extend-select = ["C4", "SIM", "TCH"]
48+
extend-select = ["C4", "SIM", "TCH", "ANN", "N", "B"]

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)