Automatically generate and edit PDF table of contents / outline
Project description
PDF Auto Outline
Automatically generate and embed a table of contents or outline in a PDF.
Install: python -m pip install pdf-auto-outline
Suggestions and contributions are welcome.
Usage
usage: pdfao [-h] [-s] [-o <path>] [-mp <n>] [-e] [-se] [-i <file>] [-t <n>] [--sioyek <path>] [--version] filename
positional arguments:
filename input pdf
options:
-h, --help show this help message and exit
-s, --straight write toc straight to pdf; skip editing
-o, --out <path> write changes to new pdf
-mp, --multiprocess <n>
spread job over n processes (faster on Linux)
-e, --edit edit pdf toc
-se, --superedit edit pdf toc (more attibutes available)
-i, --infile <file> write toc from file to pdf
-t, --tablevel <n> tab = n toc nesting levels (default 2)
--sioyek <path> for users of the Sioyek pdf viewer
--version show program's version number and exit
[!NOTE] Multiprocessing on Windows and MacOS is considerably slower than on Linux. Users are encouraged to test and see what works best for them.
Examples
Generate toc and edit before saving:
pdfao paper.pdf
Generate and save to new pdf:
pdfao paper.pdf -o new.pdf
Edit exiting pdf toc:
pdfao paper.pdf -e
A save toc to new pdf from file:
pdfao paper.pdf -o new.pdf -i outline.txt
Editing
The edit command opens the TOC in the OS default editor (result of 'start' command on Windows and 'EDITOR' environment variable on MacOS and Linux). The file schema is something like this:
Title 1 | 1
Title 2 | 2 | *
^^^^^^
optional
The essential parts of each line are:
- Indentation - 4 space characters per nesting level (or use tabs with the -t flag).
- Title text
- Delimiter - ' | ' (vertical bar with 2 spaces padding on each side)
- Page number
The optional part can be one of:
| None same as not including it
| 241.2 y-ordinate
| {<dictionary>} dictionary with more attributes for the ToC entry
For Sioyek Users
Example commands; add to prefs_user.config.
new_command _gen_toc pdfao "%{file_path}" --sioyek path/to/sioyek -mp 4
new_command _edit_toc pdfao "%{file_path}"
The sioyek library and flag are optional; they allow logging to the status bar. This is more useful for ToC generation where you may want a progress bar.
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf_auto_outline-0.1.6.tar.gz.
File metadata
- Download URL: pdf_auto_outline-0.1.6.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1826e552ecd4089071c81724d6352e655c329b6625ba3a02b6698d00a3f1dbdb
|
|
| MD5 |
90cd1b95e1decfa3eb530677f62b3375
|
|
| BLAKE2b-256 |
8d08badaeda1701d83b3bd6bc075f77e64c2bf6b0fc8c3dfa39855d54c5ac623
|
File details
Details for the file pdf_auto_outline-0.1.6-py3-none-any.whl.
File metadata
- Download URL: pdf_auto_outline-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20f80c6ae1df21b50abca705ae1e9d0e6c524e9907527aae7b5fede0f2d92d03
|
|
| MD5 |
b6b9b564c4a1fcc639c524225234061b
|
|
| BLAKE2b-256 |
7acc3f11057b048fe9d6171064b5222f207c50afb1c226bd80b11582cfbc8821
|