Quick start

Give it a long PDF and get back its outline: every heading with the page it starts on, as a flat list or nested by level.

1. Set up

Create an API key in the PageIndex Console and set it:

export PAGEINDEX_API_KEY="your-pageindex-key"

Install the SDK:

pip install -U pageindex

2. Outline a PDF

Upload the PDF with the outline you want. wait=True waits until the outline is built.

from pageindex import PageIndexClient

client = PageIndexClient(index="cloud")  # reads PAGEINDEX_API_KEY

doc_id = client.submit_document(
    "report.pdf", outline_structure="hierarchical", wait=True
)["doc_id"]

for heading in client.get_outline(doc_id)["result"]["outline"]:
    print("  " * (heading["level"] - 1) + heading["title"], heading["page"])
Financial Stability 21
  Monitoring Financial Vulnerabilities 22
  ...
OutlineWhat you get
flat (default)The headings at one level, each with its page
hierarchicalThe headings nested, each with its page and its level

A flat outline's headings have no level. A hierarchical outline also serves as the flat one.

3. Outline a document you already uploaded

A document uploaded for Page Search, Page Extract, Page Classify or Page Split has no outline. Build one by its ID:

client.build_outline(doc_id, outline_structure="hierarchical")  # waits until it is built
outline = client.get_outline(doc_id)["result"]["outline"]

The same call turns a flat outline into a hierarchical one. A document that already has the outline you ask for keeps it, free.

Price

OutlinePrice
Flat$1 per 1,000 pages
Hierarchical$2 per 1,000 pages

You pay when the outline is built; a failed build is free. Turning a flat outline into a hierarchical one costs the difference, $1 per 1,000 pages.

Next