Skip to content

Commit 3b77525

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

10 files changed

Lines changed: 612 additions & 288 deletions

File tree

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

.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+
permissions:
13+
id-token: write
14+
15+
steps:
16+
- uses: actions/checkout@master
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install uv
27+
28+
- name: Build
29+
run: |
30+
uv build
31+
pip install dist/*.whl
32+
echo "PACKAGE_VERSION=$(pip show pdf-helper | grep '^Version: ' | cut -d ' ' -f 2)" >> $GITHUB_ENV
33+
34+
- name: check-version
35+
uses: KyoriPowered/action-regex-match@v3
36+
id: check-version
37+
with:
38+
text: ${{ env.PACKAGE_VERSION }}
39+
regex: '\d+\.\d+\.\d+a\d+'
40+
41+
- name: Publish
42+
uses: pypa/gh-action-pypi-publish@release/v1
43+
if: ${{ steps.check-version.outputs.match == '' }} # If didn't match

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: 34 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,115 @@ 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+
37+
And run it using the command line:
38+
39+
```bash
40+
pdf-helper <command> [options]
41+
```
42+
43+
Or you can use uvx to run the package without installing it in a specific python environment:
3544

3645
```bash
37-
git clone https://GitHub.com/MPCodeWriter21/PDF-Helper
46+
uvx pdf-helper <command> [options]
3847
```
3948

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

4251
```bash
43-
pip install -r requirements.txt
52+
git clone https://github.com/MPCodeWriter21/PDF-Helper.git
53+
cd PDF-Helper
54+
uv run pdf-helper <command> [options]
4455
```
4556

4657
### Merge PDFs
4758

4859
Merge multiple PDFs into one PDF:
4960

5061
```bash
51-
python3 main.py merge -i <input_file_1> <input_file_2>... <input_file_n> -o <output_file>
62+
pdf-helper merge -i <input_file_1> <input_file_2>... <input_file_n> -o <output_file>
5263

5364
# 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
65+
pdf-helper merge -i 1.pdf 2.pdf 3.pdf -o new.pdf
5566
```
5667

5768
### Split PDFs
5869

5970
Split a PDF into multiple PDFs, each containing a range of pages:
6071

6172
```bash
62-
python3 main.py split -i <input_file> -o <output_folder> -s <split_point_1>,<split_point_2>
73+
pdf-helper split -i <input_file> -o <output_folder> -s <split_point_1>,<split_point_2>
6374

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

6879
# 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
80+
pdf-helper split -i my-pdf.pdf -o my-split-pdfs # No need to specify split points
7081
```
7182

7283
### Export PDF pages as image files
7384

7485
Export PDF pages as image files:
7586

7687
```bash
77-
python3 main.py to-image -i <input_file> -o <output_folder> \
88+
pdf-helper to-image -i <input_file> -o <output_folder> \
7889
-p <page_number_1>,<page_number_2>,...,<page_number_n> -s <scale_factor>
7990

8091
# 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
92+
pdf-helper to-image -i 1.pdf -o images -p 1-3,6 -s 1
8293

8394
# E.g. Export all pages from a PDF with scale 2
84-
python3 main.py to-image -i my-pdf.pdf -o my-images
95+
pdf-helper to-image -i my-pdf.pdf -o my-images
8596
```
8697

8798
### Remove pages from a PDF
8899

89100
Remove pages from a PDF:
90101

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

94105
# 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
106+
pdf-helper remove-pages -i 1.pdf -o new.pdf -p 1-3,6
96107
```
97108

98109
### Export text from a PDF
99110

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

102113
```bash
103-
python3 main.py extract-text -i <input_file> -o <output_file_name>
114+
pdf-helper extract-text -i <input_file> -o <output_file_name>
104115

105116
# 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
117+
pdf-helper extract-text -i my-pdf.pdf -o my-text.txt
107118
```
108119

109120
### Export one or multiple images as a PDF file
110121

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

113124
```bash
114-
python3 main.py image-to-pdf -i <image_1> <image_2> <image_3> ... -o <output_file>
125+
pdf-helper image-to-pdf -i <image_1> <image_2> <image_3> ... -o <output_file>
115126

116127
# E.g. Take 1.png, 2.jpg, and 3.png and create a PDF named 123.pdf and override
117128
# if already exists
118-
python3 main.py image-to-pdf -i 1.png 2.jpg 3.png -o 123.pdf -f
129+
pdf-helper image-to-pdf -i 1.png 2.jpg 3.png -o 123.pdf -f
119130
```
120131

121132
About
122133
-----
123134

124135
Author: [CodeWriter21](https://github.com/MPCodeWriter21)
125136

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

128139
Donations
129140
---------

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)