A tool to edit the outline of a PDF file and shift page numbers to match printed ones
Project description
PDF_tools_outline
A simple CLI tool made for all the students who started using PDFs instead of paper book in order to save some weight in their backpack but stumbled into the problem of missing outline and shifted page numbering cause by preface, index and other additions.
GUIDA IN ITALIANO QUI
How to install
uv
uv tool install PDF_tools_outline
pipx
pipx install PDF_tools_outline
Development
Clone the repo and install the hooks. It may be necessary to give execution privileges to hooks files
git clone https://github.com/aGenius05/PDF_outline.git
cp ./hooks/* .git/hooks
uv
It's recommended that you use uv cause it makes everything much simpler
uv sync
uv pip install -e .
manual install
Manual installation is a bit trickier, you'll need python3 and pikepdf module. You should install it in a virtual environment through pip3:
python3 -m venv /path/to/venv/
source /path/to/venv/bin/activate
pip3 install -r requirements.txt
pip3 install -e .
Indeed requirements.txt contains the version I used and it's guaranteed that it will work on you're computer too.
Testing
This project has some automated tests written in the tests/ dir. They are unittest tests and are configured to run before commits and pushes via the hooks. The material used in the tests is described in this file.
Publishing
A Github Action is configured to look for commits on the main branch which also have a tag, build the package for those and publish them automatically on PyPi
Note that the hooks make it impossible to push to main tagged commit that haven't passed unittests first.
It's also possible to manually send a package version to PyPi using the command:
uv build
uv publish
oppure con pip
python3 -m build
python3 -m twine dist/*
Usage
The usage is very simple:
PDF_outline_add [file_input.pdf] [file_index] {-o [file_output.pdf]} {-s [first_page]}
where file_input is the inpput pdf, first_page is the number of the first page in the "wrong" ordering, file_index is the file where the outline lays and file_output is the output's file name. If file_output isn't specified file_input will be overwritten.
The outline file has the following syntax
[starting page number] [section's name]
Subsections/paragraphs, if present, are written adding one additional space in front of their line:
1 first chapter
2 section 1.1
3 section 1.2
paragraph
...
Pages befor the start of the "real" book, if present, are written using roman numeration:
i prefazione
v indicie
1 inizio libro
...
Gemini Gem
To generate index file it's very useful having a custom Agent for Gemini(Gem). To do so give it the prompt.
TODO
- export index from existing pdf
- right numeration on pages with double pages(different on index and book eventually)
- y-ordinate for outline entries?
- in place edit?
- tablevel to accept files with n-tabs indentation
- check if previus uri-link need to be preserved and add option eventually
- automatic book start page recognition made on main instead of inside the function(must work also for the wirter and i don't want to repeat the same operation over and over)
Project details
Release history Release notifications | RSS feed
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_tools_outline-2.0.0.tar.gz.
File metadata
- Download URL: pdf_tools_outline-2.0.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adf67bead47202d98e49946170e03886b619fb202e85746b4355cedc4b97fb2b
|
|
| MD5 |
5427ee5b316de38b783d5663a5542546
|
|
| BLAKE2b-256 |
94803951301c63bb551c0d60e01bea0ddae89c43f866be157645bac55e36f11c
|
Provenance
The following attestation bundles were made for pdf_tools_outline-2.0.0.tar.gz:
Publisher:
python-publish.yml on aGenius05/PDF_tools_outline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_tools_outline-2.0.0.tar.gz -
Subject digest:
adf67bead47202d98e49946170e03886b619fb202e85746b4355cedc4b97fb2b - Sigstore transparency entry: 1343419452
- Sigstore integration time:
-
Permalink:
aGenius05/PDF_tools_outline@efcdcc42fbb6c0937daf376273c9523f71a91700 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/aGenius05
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@efcdcc42fbb6c0937daf376273c9523f71a91700 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdf_tools_outline-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pdf_tools_outline-2.0.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7845aff900e02f3e58e85424fb4aea6d302ce611b10cf49aaeae03b705cd9c89
|
|
| MD5 |
8273863468a4f9dcc1bbbf89cf52c8e2
|
|
| BLAKE2b-256 |
e287f293cccf074a9de479b3ba0ce0f41fb9785e8c3c612815627d8631305379
|
Provenance
The following attestation bundles were made for pdf_tools_outline-2.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on aGenius05/PDF_tools_outline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_tools_outline-2.0.0-py3-none-any.whl -
Subject digest:
7845aff900e02f3e58e85424fb4aea6d302ce611b10cf49aaeae03b705cd9c89 - Sigstore transparency entry: 1343419457
- Sigstore integration time:
-
Permalink:
aGenius05/PDF_tools_outline@efcdcc42fbb6c0937daf376273c9523f71a91700 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/aGenius05
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@efcdcc42fbb6c0937daf376273c9523f71a91700 -
Trigger Event:
push
-
Statement type: