Skip to main content

pdf-page-annotator

A light weight library to extract the table of contents and tag them to the pages containing the content.

To understand the structure of a PDF and for effective retrieval, it is important to understand the contents and know exactly what page contains what.

When the need to extract a specific subsection of the pdf comes up, it can be found in either of the two places--

  1. In a section of a semi-structured (one with a structure and TOC) document.
  2. In an unknown section or in a fragmented form inside an unstructured document.

For the more extreme case of unstructured document, we have to perform an analysis on the whole document. Each time we want to find some informationin an exhaustive fashion (Because naive vector retrieval can't do that).

So, for the semi-structured documents, conventionally all important PDF documents worth indexing have a TOC, we can perform an initial TOC sweep, and extract relevant page numbers for each TOC item. In this manner, when we have to search for something exhaustively, instead of having to sesrch through the whole document, we can only search through the TOC to find the relevant pages, and then extract information from only those pages, saving time and tokens.

Installation

pip install pdf-page-annotator

Usage

  1. Import and initialize the PDFAnnotator class
from pdf_page_annotator import PDFAnnotator
annotator = PDFAnnotator(pdf_path="path_to_your_pdf_file", verbose=True) # `verbose=True` logs progress on the console, default is `False`
  1. Extract the contents
annotator.run_extraction_pipeline()
  1. Access the content list
print(annotator.content[0].unique_title, annotator.content[0].start_page, annotator.content[0].end_page)

Enjoy!

Release files for pdf-page-annotator 0.3.0

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-page-annotator 0.3.0
File Size Uploaded
pdf_page_annotator-0.3.0.tar.gz 17.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdf-page-annotator 0.3.0
File Interpreter ABI Platform
pdf_page_annotator-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.2 kB

Release files / pdf_page_annotator-0.3.0.tar.gz

Download URL pdf_page_annotator-0.3.0.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d7adc04df18d6cf744fa990a162f45b9b885d626827ac480f6eccac95e30f92f
BLAKE2b-256 checksum
How to use checksums
bdc3d808c5f668b39a19a1ccd2a300457ed44164c1262404cb693013e64afd60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release files / pdf_page_annotator-0.3.0-py3-none-any.whl

Download URL pdf_page_annotator-0.3.0-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e2e880833b2c4eecf7cc18f78b6c6ad8a0b41b462e7cf16685a881cf8c799a2
BLAKE2b-256 checksum
How to use checksums
19134ea937ca42d2531631ea5d691627f01d454e51b9b346b53785014b749f1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

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