Skip to main content

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 
  |  Point(72.0, 363.9)		x and y coords
  |  {<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}" --sioyek path/to/sioyek -e

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

pdf_auto_outline-0.1.5.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_auto_outline-0.1.5-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pdf_auto_outline-0.1.5.tar.gz.

File metadata

  • Download URL: pdf_auto_outline-0.1.5.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for pdf_auto_outline-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c94c8d2adf5e8938945c127bfe6e4161b1b95e56803113ba5e712390123d5d8b
MD5 b9c6fbcab1b47d5c17ed5c1ce5357e44
BLAKE2b-256 d856e60d0abecbeda3f8bb32cb9018b9d7ce8edf4f8f6da8781268825f432d08

See more details on using hashes here.

File details

Details for the file pdf_auto_outline-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_auto_outline-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f282e59b76bc0abb8358f211c353c6ae8ca267d229a5756edb82f2cb512712ce
MD5 c2cff76ab05a3a92406eec40770397d3
BLAKE2b-256 5f223f858a58410af65a99b021512ff175072f6821f93d2435c036e8d9f38729

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page