Skip to main content

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

Project description

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!

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_page_annotator-0.3.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

pdf_page_annotator-0.3.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file pdf_page_annotator-0.3.0.tar.gz.

File metadata

  • Download URL: pdf_page_annotator-0.3.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for pdf_page_annotator-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d7adc04df18d6cf744fa990a162f45b9b885d626827ac480f6eccac95e30f92f
MD5 1ccf0b98f2f99dad7109c42adf53b847
BLAKE2b-256 bdc3d808c5f668b39a19a1ccd2a300457ed44164c1262404cb693013e64afd60

See more details on using hashes here.

File details

Details for the file pdf_page_annotator-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_page_annotator-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e2e880833b2c4eecf7cc18f78b6c6ad8a0b41b462e7cf16685a881cf8c799a2
MD5 7d0c90d7eb8b4eaca6f4816e7455d5f5
BLAKE2b-256 19134ea937ca42d2531631ea5d691627f01d454e51b9b346b53785014b749f1f

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