pdf-auto-outline 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pdf_auto_outline-0.1.1/PKG-INFO +73 -0
- pdf_auto_outline-0.1.1/README.md +56 -0
- {pdf_auto_outline-0.1.0 → pdf_auto_outline-0.1.1}/pyproject.toml +15 -1
- pdf_auto_outline-0.1.1/src/pdf_auto_outline/__init__.py +1 -0
- {pdf_auto_outline-0.1.0 → pdf_auto_outline-0.1.1}/src/pdf_auto_outline/main.py +9 -5
- pdf_auto_outline-0.1.0/PKG-INFO +0 -46
- pdf_auto_outline-0.1.0/README.md +0 -36
- pdf_auto_outline-0.1.0/src/pdf_auto_outline/__init__.py +0 -1
- {pdf_auto_outline-0.1.0 → pdf_auto_outline-0.1.1}/src/pdf_auto_outline/__main__.py +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pdf-auto-outline
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Automatically generate and edit PDF table of contents / outline
|
|
5
|
+
Author: Rossikos
|
|
6
|
+
Author-email: Rossikos <216631970+rossikos@users.noreply.github.com>
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Dist: pymupdf-layout>=1.26.6
|
|
11
|
+
Requires-Dist: sioyek ; extra == 'sioyek'
|
|
12
|
+
Requires-Python: >=3.13
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/rossikos/pdf-auto-outline/issues
|
|
14
|
+
Project-URL: Homepage, https://github.com/rossikos/pdf-auto-outline
|
|
15
|
+
Provides-Extra: sioyek
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# PDF Auto Outline
|
|
19
|
+
|
|
20
|
+
Automatically generate and embed a table of contents or outline in a PDF.
|
|
21
|
+
|
|
22
|
+
Install: `python -m pip install pdf-auto-outline`
|
|
23
|
+
|
|
24
|
+
Suggestions and contributions are welcome.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
usage: pdfao [-h] [-s] [-o <path>] [-mp <n>] [-e] [-se] [-i <file>] [-t <n>] [--sioyek <path>] [--version] filename
|
|
30
|
+
|
|
31
|
+
positional arguments:
|
|
32
|
+
filename input pdf
|
|
33
|
+
|
|
34
|
+
options:
|
|
35
|
+
-h, --help show this help message and exit
|
|
36
|
+
-s, --straight write toc straight to pdf; skip editing
|
|
37
|
+
-o, --out <path> write changes to new pdf
|
|
38
|
+
-mp, --multiprocess <n>
|
|
39
|
+
spread job over n processes (faster on Linux)
|
|
40
|
+
-e, --edit edit pdf toc
|
|
41
|
+
-se, --superedit edit pdf toc (more attibutes available)
|
|
42
|
+
-i, --infile <file> write toc from file to pdf
|
|
43
|
+
-t, --tablevel <n> tab = n toc nesting levels (default 2)
|
|
44
|
+
--sioyek <path> for users of the Sioyek pdf viewer
|
|
45
|
+
--version show program's version number and exit
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
# Examples
|
|
49
|
+
|
|
50
|
+
Generate toc and edit before saving:
|
|
51
|
+
`pdfao paper.pdf`
|
|
52
|
+
|
|
53
|
+
Generate and save to new pdf:
|
|
54
|
+
`pdfao paper.pdf -o new.pdf`
|
|
55
|
+
|
|
56
|
+
Edit exiting pdf toc:
|
|
57
|
+
`pdfao paper.pdf -e`
|
|
58
|
+
|
|
59
|
+
A save toc to new pdf from file:
|
|
60
|
+
`pdfao paper.pdf -o new.pdf -i outline.txt`
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## For Sioyek Users
|
|
64
|
+
|
|
65
|
+
Example commands; add to `prefs_user.config`.
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
new_command _gen_toc pdfao "%{file_path}" --sioyek path/to/sioyek -mp 4
|
|
69
|
+
new_command _edit_toc pdfao path/to/pdfao.py "%{file_path}" --sioyek path/to/sioyek -se
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If you don't wish to install from PyPI, download source and use `python3 -m path/to/src/pdf_auto_outline` in place of `pdfao`.
|
|
73
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# PDF Auto Outline
|
|
2
|
+
|
|
3
|
+
Automatically generate and embed a table of contents or outline in a PDF.
|
|
4
|
+
|
|
5
|
+
Install: `python -m pip install pdf-auto-outline`
|
|
6
|
+
|
|
7
|
+
Suggestions and contributions are welcome.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
usage: pdfao [-h] [-s] [-o <path>] [-mp <n>] [-e] [-se] [-i <file>] [-t <n>] [--sioyek <path>] [--version] filename
|
|
13
|
+
|
|
14
|
+
positional arguments:
|
|
15
|
+
filename input pdf
|
|
16
|
+
|
|
17
|
+
options:
|
|
18
|
+
-h, --help show this help message and exit
|
|
19
|
+
-s, --straight write toc straight to pdf; skip editing
|
|
20
|
+
-o, --out <path> write changes to new pdf
|
|
21
|
+
-mp, --multiprocess <n>
|
|
22
|
+
spread job over n processes (faster on Linux)
|
|
23
|
+
-e, --edit edit pdf toc
|
|
24
|
+
-se, --superedit edit pdf toc (more attibutes available)
|
|
25
|
+
-i, --infile <file> write toc from file to pdf
|
|
26
|
+
-t, --tablevel <n> tab = n toc nesting levels (default 2)
|
|
27
|
+
--sioyek <path> for users of the Sioyek pdf viewer
|
|
28
|
+
--version show program's version number and exit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
# Examples
|
|
32
|
+
|
|
33
|
+
Generate toc and edit before saving:
|
|
34
|
+
`pdfao paper.pdf`
|
|
35
|
+
|
|
36
|
+
Generate and save to new pdf:
|
|
37
|
+
`pdfao paper.pdf -o new.pdf`
|
|
38
|
+
|
|
39
|
+
Edit exiting pdf toc:
|
|
40
|
+
`pdfao paper.pdf -e`
|
|
41
|
+
|
|
42
|
+
A save toc to new pdf from file:
|
|
43
|
+
`pdfao paper.pdf -o new.pdf -i outline.txt`
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## For Sioyek Users
|
|
47
|
+
|
|
48
|
+
Example commands; add to `prefs_user.config`.
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
new_command _gen_toc pdfao "%{file_path}" --sioyek path/to/sioyek -mp 4
|
|
52
|
+
new_command _edit_toc pdfao path/to/pdfao.py "%{file_path}" --sioyek path/to/sioyek -se
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If you don't wish to install from PyPI, download source and use `python3 -m path/to/src/pdf_auto_outline` in place of `pdfao`.
|
|
56
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pdf-auto-outline"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.1"
|
|
4
4
|
description = "Automatically generate and edit PDF table of contents / outline"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -11,6 +11,15 @@ dependencies = [
|
|
|
11
11
|
"pymupdf-layout>=1.26.6",
|
|
12
12
|
]
|
|
13
13
|
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
sioyek = ["sioyek"]
|
|
22
|
+
|
|
14
23
|
[project.scripts]
|
|
15
24
|
pdfao = "pdf_auto_outline.main:main"
|
|
16
25
|
pdf-auto-outline = "pdf_auto_outline.main:main"
|
|
@@ -18,3 +27,8 @@ pdf-auto-outline = "pdf_auto_outline.main:main"
|
|
|
18
27
|
[build-system]
|
|
19
28
|
requires = ["uv_build>=0.9.7,<0.10.0"]
|
|
20
29
|
build-backend = "uv_build"
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
"Homepage" = "https://github.com/rossikos/pdf-auto-outline"
|
|
33
|
+
"Bug Tracker" = "https://github.com/rossikos/pdf-auto-outline/issues"
|
|
34
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.1'
|
|
@@ -96,7 +96,6 @@ def generate_toc_nnet(pdfpath, worker_cnt=3) -> list:
|
|
|
96
96
|
log('\nCancelled')
|
|
97
97
|
exit()
|
|
98
98
|
|
|
99
|
-
log('')
|
|
100
99
|
|
|
101
100
|
return [j for i in pg_nums for j in results[i]]
|
|
102
101
|
|
|
@@ -214,7 +213,6 @@ def parse_txtfile(txtfile='outline.txt', tablevel=2) -> list:
|
|
|
214
213
|
return toc_entries
|
|
215
214
|
|
|
216
215
|
def embed_toc(pdfpath, toc_entries, newfile=''):
|
|
217
|
-
print(len(toc_entries))
|
|
218
216
|
doc = pymupdf.open(pdfpath)
|
|
219
217
|
doc.set_toc(toc_entries, collapse=2)
|
|
220
218
|
if newfile:
|
|
@@ -241,14 +239,19 @@ def main():
|
|
|
241
239
|
parser.add_argument('-i', '--infile', type=str, metavar='<file>', help='write toc from file to pdf')
|
|
242
240
|
parser.add_argument('-t', '--tablevel', type=int, metavar='<n>', help='tab = n toc nesting levels (default 2)', default=2)
|
|
243
241
|
parser.add_argument('--sioyek', type=str, metavar='<path>', help='for users of the Sioyek pdf viewer')
|
|
244
|
-
parser.add_argument('--version', action='version', version='%(prog)s 0.1.
|
|
242
|
+
parser.add_argument('--version', action='version', version='%(prog)s 0.1.1')
|
|
245
243
|
|
|
246
244
|
args = parser.parse_args()
|
|
247
245
|
|
|
248
246
|
if args.sioyek:
|
|
249
247
|
from sioyek.sioyek import Sioyek
|
|
250
|
-
|
|
251
|
-
SIOYEK = Sioyek(
|
|
248
|
+
global SIOYEK
|
|
249
|
+
SIOYEK = Sioyek(args.sioyek)
|
|
250
|
+
if args.out:
|
|
251
|
+
args.out = os.path.join(
|
|
252
|
+
os.path.dirname(args.filename),
|
|
253
|
+
args.out
|
|
254
|
+
)
|
|
252
255
|
# local_db = args.sioyek[1]
|
|
253
256
|
# shared_db = args.sioyek[2]
|
|
254
257
|
# pdf_path = args.sioyek[3]
|
|
@@ -267,6 +270,7 @@ def main():
|
|
|
267
270
|
start = perf_counter()
|
|
268
271
|
toc_entries = generate_toc_nnet(args.filename, args.multiprocess)
|
|
269
272
|
end = perf_counter()
|
|
273
|
+
log('')
|
|
270
274
|
log(f"finished in {end - start:<4.1f} s")
|
|
271
275
|
toc_entries = align_toc_lvls(toc_entries)
|
|
272
276
|
if args.straight:
|
pdf_auto_outline-0.1.0/PKG-INFO
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: pdf-auto-outline
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Automatically generate and edit PDF table of contents / outline
|
|
5
|
-
Author: Rossikos
|
|
6
|
-
Author-email: Rossikos <216631970+rossikos@users.noreply.github.com>
|
|
7
|
-
Requires-Dist: pymupdf-layout>=1.26.6
|
|
8
|
-
Requires-Python: >=3.13
|
|
9
|
-
Description-Content-Type: text/markdown
|
|
10
|
-
|
|
11
|
-
# PDF Auto Outline
|
|
12
|
-
|
|
13
|
-
A simple python program to automatically generate and embed a table of contents or outline in a PDF.
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
usage: pdfao [-h] [-s] [-o <path>] [-mp <n>] [-e] [-se] [-i <file>] [-t <n>] [--sioyek <path>] [--version] filename
|
|
19
|
-
|
|
20
|
-
positional arguments:
|
|
21
|
-
filename input pdf
|
|
22
|
-
|
|
23
|
-
options:
|
|
24
|
-
-h, --help show this help message and exit
|
|
25
|
-
-s, --straight write toc straight to pdf; skip editing
|
|
26
|
-
-o, --out <path> write changes to new pdf
|
|
27
|
-
-mp, --multiprocess <n>
|
|
28
|
-
spread job over n processes (faster on linux)
|
|
29
|
-
-e, --edit edit pdf toc
|
|
30
|
-
-se, --superedit edit pdf toc (more attibutes available)
|
|
31
|
-
-i, --infile <file> write toc from file to pdf
|
|
32
|
-
-t, --tablevel <n> tab = n toc nesting levels (default 2)
|
|
33
|
-
--sioyek <path> for users of the Sioyek pdf viewer
|
|
34
|
-
--version show program's version number and exit
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## For Sioyek Users
|
|
38
|
-
|
|
39
|
-
Example commands; add to prefs_user.config.
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
new_command _gen_toc python3 path/to/pdfao.py "%{file_path}" --sioyek path/to/sioyek -mp 4
|
|
43
|
-
new_command _edit_toc python3 path/to/pdfao.py "%{file_path}" --sioyek path/to/sioyek -e
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
pdf_auto_outline-0.1.0/README.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# PDF Auto Outline
|
|
2
|
-
|
|
3
|
-
A simple python program to automatically generate and embed a table of contents or outline in a PDF.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
usage: pdfao [-h] [-s] [-o <path>] [-mp <n>] [-e] [-se] [-i <file>] [-t <n>] [--sioyek <path>] [--version] filename
|
|
9
|
-
|
|
10
|
-
positional arguments:
|
|
11
|
-
filename input pdf
|
|
12
|
-
|
|
13
|
-
options:
|
|
14
|
-
-h, --help show this help message and exit
|
|
15
|
-
-s, --straight write toc straight to pdf; skip editing
|
|
16
|
-
-o, --out <path> write changes to new pdf
|
|
17
|
-
-mp, --multiprocess <n>
|
|
18
|
-
spread job over n processes (faster on linux)
|
|
19
|
-
-e, --edit edit pdf toc
|
|
20
|
-
-se, --superedit edit pdf toc (more attibutes available)
|
|
21
|
-
-i, --infile <file> write toc from file to pdf
|
|
22
|
-
-t, --tablevel <n> tab = n toc nesting levels (default 2)
|
|
23
|
-
--sioyek <path> for users of the Sioyek pdf viewer
|
|
24
|
-
--version show program's version number and exit
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## For Sioyek Users
|
|
28
|
-
|
|
29
|
-
Example commands; add to prefs_user.config.
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
new_command _gen_toc python3 path/to/pdfao.py "%{file_path}" --sioyek path/to/sioyek -mp 4
|
|
33
|
-
new_command _edit_toc python3 path/to/pdfao.py "%{file_path}" --sioyek path/to/sioyek -e
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.1.0'
|
|
File without changes
|