Skip to main content

a pdf ToC CLI tool

Project description

PDF ToC

a CLI tool to easily extract / edit ToC(Table of Content, or bookmark) of pdf file

demo

Requirements

  • python >= 3.7
    • for python 3.6 support, use pdf-toc == 1.1.4
  • PyMuPDF >= 1.19

Installation

install from pypi

pip install pdf-toc

install from the repo directly

pip install git+https://github.com/HareInWeed/pdf-toc.git@master#egg=pdf-toc

install a specific version

pip install git+https://github.com/HareInWeed/pdf-toc.git@v1.1.4#egg=pdf-toc

Usage

usage: pdf-toc [-h] [--version] [--show-toc {json,toc}] [-t TOC] [-d DEST]
               [-T {json,toc}] [-f] [-m]
               source

pdf ToC modifier.

positional arguments:
  source                source pdf file directory

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --show-toc {json,toc}
                        print the toc info of the source file and exit
  -t TOC, --toc TOC     toc info used to embed in the result file. leave it
                        empty to read toc from stdin
  -d DEST, --dest DEST  destination directory for result file
  -T {json,toc}, --type {json,toc}
                        specify format of ToC file. leave it empty to let the
                        tool determine the format, (from file suffix)
  -f, --force           overwrite dist file if it exist
  -m, --modify          modified the original file instead of create a new one

Examples

show the toc of file.pdf in toc format

pdf-toc --show-toc toc file.pdf

Generate a new file with content of file.pdf and toc in toc.txt

pdf-toc -t toc.txt -d new-file.pdf file.pdf

Replace the toc of file.pdf with one in toc.txt

pdf-toc -m -t toc.txt file.pdf

ToC file

Two types of toc file are supported

One is json, which mostly follow the specification of PyMuPDF, but in json format. See PyMuPDF docs and toc_json.md for detail

The other is a special data format, which provides ease of modification and additional functionalities. Check out toc.md for detail

Licence

MIT

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-toc-1.2.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file pdf-toc-1.2.0.tar.gz.

File metadata

  • Download URL: pdf-toc-1.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.9

File hashes

Hashes for pdf-toc-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f44516b934ea0a0772f6a77eb031fce5e2dc063439f144a826acef6cff3e119e
MD5 82a58ea007f652f3a6e92a7a60707a94
BLAKE2b-256 8ba71e4b8164282d13a1a488eacffa726c0c744a9327b4e4e6d4ed1b0b64235b

See more details on using hashes here.

Supported by

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