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
...
| Outline | What you get |
|---|---|
flat (default) | The headings at one level, each with its page |
hierarchical | The 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
| Outline | Price |
|---|---|
| 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
- Ask PageIndex Agent: it follows the outline to the pages that answer.
- Upload and manage: upload options, collections and folders.
- API reference: build and read outlines over HTTP.