Skip to main content

pdf-add-outline

Add an outline to a PDF file. What it says on the tin.

Installation

Install through pip:

pip install pdf-add-outline

Usage

$ pdf-add-outline --help
usage: pdf-add-outline [-h] -o OUTPUT [-d] [--increment INCREMENT] <pdf_file> <toc_file>

Add an outline to a PDF.

positional arguments:
  <pdf_file>            Input PDF
  <toc_file>            JSON- or TXT-encoded ToC file (file type suffix required)

options:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Resultant filename (required)
  -d, --dry             Output the parsed OutlineItem structure; don't touch the PDF
  --increment INCREMENT
                        Increase all entries by <increment> amount

Example

$ pdf-add-outline tests/fixtures/Situated_Learning.pdf tests/fixtures/situated_learning.txt -o situated_with_outline.pdf

ToC File Formats

$ head tests/fixtures/situated_learning.json
[
    ["Series Foreword", 11, []],
    ["Foreword by William F. Hanks", 13, []],
    ["Acknowledgments", 25, []],
    ["1. Legitimate Peripheral Participation", 27, [
        ["From apprenticeship to situated learning", 32, []],
        ["From situated learning to legitimate peripheral participation", 34, []],
        ["An analytic perspective on learning", 37, []],
        ["With legitimate peripheral participation", 39, []],
        ["The organization of this monograph", 42, []]
$ head tests/fixtures/situated_learning.txt
Series Foreword, 11
Foreword by William F. Hanks, 13
Acknowledgments, 25
1. Legitimate Peripheral Participation, 27
    From apprenticeship to situated learning, 32
    From situated learning to legitimate peripheral participation, 34
    An analytic perspective on learning, 37
    With legitimate peripheral participation, 39
    The organization of this monograph, 42
2. Practice, Person, Social World, 45

Development

  1. Prerequisites: Clone the repository. Install Poetry.

  2. Run poetry install in the root of the directory.

  3. Run the tests.

    $ poetry run pytest tests
    collected 4 items
    
    tests/test_parsing.py ....        [100%]
    
    ========== 4 passed in 0.03s ===========
    
  4. Run mypy.

    $ poetry run mypy pdf_add_outline tests
    Success: no issues found in 4 source files
    
  5. Run black.

    $ poetry run black pdf_add_outline tests
    All done! ✨ 🍰 ✨
    4 files left unchanged.
    

Acknowledgements

The excellent PikePDF package, which wraps the QPDF library. Jean Lave and Etienne Wenger's Situated Learning for the example (and test) table of contents.

Release files for pdf-add-outline 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdf-add-outline 0.1.1
File Size Uploaded
pdf_add_outline-0.1.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdf-add-outline 0.1.1
File Interpreter ABI Platform
pdf_add_outline-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / pdf_add_outline-0.1.1.tar.gz

Download URL pdf_add_outline-0.1.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
72c7359dc3b176d3f45ab380cfb0e0ac26ded968326698378b9e4362f37357b2
BLAKE2b-256 checksum
How to use checksums
67d102af69e09707cb260762308ee3ff58ce680af014cd073ca89bd163fd724d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/22.1.0

Release files / pdf_add_outline-0.1.1-py3-none-any.whl

Download URL pdf_add_outline-0.1.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42ba53f60bf21afb2ee24551528be269f137b81a91a479f005d3cd253f5f9e78
BLAKE2b-256 checksum
How to use checksums
66900624e9869c3012a7de277628d8df903d184cc576644cda3cea86cd1616ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/22.1.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page