A Python library and CLI tool that uses LLMs to enhance PDF files
Project description
pdfalive
A Python library and set of CLI tools to bring PDF files alive with the magic of LLMs.
Features:
- Automatically generate a Table of Contents via PDF Bookmarks for PDF file using LLMs. Supports arbitrarily large files with intelligent batching.
- Automatically detect if OCR is needed to parse text from raster data. If needed, performs OCR via Tesseract OCR library.
- Choose which LLM to use from any vendor. Supports using local models via
ollamaas well. Retry logic included for handling rate limits.
Installation
the tesseract library is required for OCR. This is used for PDFs where text is not parsed. On MacOS, can install via Homebrew:
brew install tesseract
You can then install the pdfalive package via pip for example:
pip install pdfalive
Usage
To use the CLIs described below, you can install the python package (pip install pdfalive), or run the cli directly using uvx:
uvx pdfalive generate-toc input.pdf output.pdf
More detailed examples of the CLI sub-commands are provided below.
You can also use --help on the main command-line and any of the sub-commands to get an idea of the different options supported.
generate-toc
Automatically generate clickable Table of Contents (e.g. using PDF bookmarks) for a PDF file by extracting features from the PDF and then calling an LLM to infer the pages and section names from these.
Example usage:
pdfalive generate-toc input.pdf output.pdf
By default we use the latest OpenAI ChatGPT available (run with --help to check what is the latest model we use as default), but you can change this by setting the model as part of invocation:
pdfalive generate-toc --model-identifier 'claude-sonnet-4-5' input.pdf output.pdf
Model names should match the identifiers used by LangChain, which generally line up with the names used by the various provider APIs themselves.
Note that for using Anthropic models you'd want to set your api key via the environment variable ANTHROPIC_API_KEY. Similar mechanisms apply to OpenAI (OPENAI_API_KEY) and other vendors.
Development
We use uv to manage the library. To install locally can run e.g. with:
uv sync
uv pip install -e .
We use ruff for formatting and linting, mypy for static type checking, and pytest for running unit-tests. We also use pre-commit for ensuring high-quality commits.
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 pdfalive-0.2.0.tar.gz.
File metadata
- Download URL: pdfalive-0.2.0.tar.gz
- Upload date:
- Size: 775.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2c9c9d66a7e443935c75f9ff83fece4261dabff4a35528fd8313b42666bad97
|
|
| MD5 |
15a5b7d7690ea55b32aff714d2f27628
|
|
| BLAKE2b-256 |
e13971ddd3978f08cbf5251dc0a072d654e428c30ffbbaa438b2e78bfd0788c3
|
Provenance
The following attestation bundles were made for pdfalive-0.2.0.tar.gz:
Publisher:
publish-to-pypi.yml on promptromp/pdfalive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfalive-0.2.0.tar.gz -
Subject digest:
d2c9c9d66a7e443935c75f9ff83fece4261dabff4a35528fd8313b42666bad97 - Sigstore transparency entry: 748385353
- Sigstore integration time:
-
Permalink:
promptromp/pdfalive@633c7f45761df3a97d16da6808e1279e94a29b0d -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/promptromp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@633c7f45761df3a97d16da6808e1279e94a29b0d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdfalive-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pdfalive-0.2.0-py3-none-any.whl
- Upload date:
- Size: 132.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
739d62c77e95a72eb92581df0f001c7528fea66b81a917252021dc935143ebae
|
|
| MD5 |
2d88f6c3227d510a7f54d525b4d82938
|
|
| BLAKE2b-256 |
384a4361b079d2f755344730b6b8a2255a83993f5a30fddeb9b85d8238c74567
|
Provenance
The following attestation bundles were made for pdfalive-0.2.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on promptromp/pdfalive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfalive-0.2.0-py3-none-any.whl -
Subject digest:
739d62c77e95a72eb92581df0f001c7528fea66b81a917252021dc935143ebae - Sigstore transparency entry: 748385359
- Sigstore integration time:
-
Permalink:
promptromp/pdfalive@633c7f45761df3a97d16da6808e1279e94a29b0d -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/promptromp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@633c7f45761df3a97d16da6808e1279e94a29b0d -
Trigger Event:
push
-
Statement type: