Overview
WhenpageChunks: true is passed to ToMarkdown() or ToText(), the return value is a JSON string containing an array of page objects — one per page — rather than a single concatenated string. Each object in the array follows the schema described on this page.
Why use page chunks?
Page chunking is the recommended approach for any pipeline that needs to process, search, or embed a PDF’s content. Rather than working with one large string, you get a structured array where each page is a self-contained unit carrying both its text and the metadata needed to make that text useful. This matters most in RAG applications, where you need to attach source information — file path, page number, document title — to every embedded chunk so that retrieved passages can be traced back to their origin. The layout data inpage_boxes adds another layer of utility: you can filter out headers, footers, and captions before embedding, or treat tables and body text differently depending on your retrieval strategy.
Rather than post-processing a flat Markdown string and trying to guess where page boundaries or section headings fall, chunking gives you that structure directly from the PDF’s own layout engine.
Example — extracting page numbers and first 100 characters of text from each chunk:
Chunk schema
Each item in the returned JSON array is an object with four top-level keys:metadata
Contains both document-level properties (consistent across all chunks) and page-level properties (unique per chunk).
string
The PDF version string, e.g.
"PDF 1.7".string
Document title from PDF metadata. Empty string if not set.
string
Document author from PDF metadata. Empty string if not set.
string
The application that originally created the PDF.
string
The application that produced or converted the PDF.
string
PDF creation date string in
D:YYYYMMDDHHmmSSZ format.string
Date the PDF was last modified, in the same format as
creationDate.string | null
Encryption method if the document is encrypted, otherwise
null.string
The file path of the source document as provided to
ToMarkdown().integer
Total number of pages in the document.
integer
The 1-based page number this chunk represents.
Usage example
toc_items
A list of Table of Contents entries that fall on this page. Each entry is an array in the format [level, title, page_number].
integer
Heading hierarchy depth.
1 = top-level chapter, 2 = section, 3 = subsection, etc.string
The heading text as it appears in the Table of Contents.
integer
The page number the TOC entry points to (1-based).
toc_items is an empty array [] for pages that have no TOC entries, or for documents without a Table of Contents. Always check before iterating.Usage example
page_boxes
A list of layout elements detected on the page by the layout analysis engine. Each element describes a discrete visual block — a paragraph, heading, image, table, list item — along with its position on the page and its character offsets within the page’s text string.
integer
Zero-based position of this box in the page’s reading order (top to bottom).
string
The type of layout element detected. See the box classes table below.
[float, float, float, float]
Bounding box of the element in PDF page coordinates:
[x0, y0, x1, y1]. Origin is the top-left of the page. Units are PDF points (1 pt = 1/72 inch).[int, int]
Character offsets into the page’s
text string: [start, end]. Use these to slice the exact text that corresponds to this layout element.Box classes
Usage example — extract only headings
Usage example — get bounding boxes for all images
text
The full Markdown-formatted text content of the page as a single string. Headings, bold text, tables, and list items are represented using standard Markdown syntax.
string
Markdown string for the entire page. Newlines separate logical blocks. Images that cannot be extracted are replaced with a placeholder such as
==> picture [535 x 193] intentionally omitted <==.The character offsets in each
page_boxes[n]["pos"] correspond directly to positions within this string. Use them to precisely extract the text for any layout element without re-parsing the Markdown.Usage example — slice text by layout element
Full iteration example
Related
JSON Schema
Full schema reference for the JSON output, including text, image, table, and drawing blocks with bounding boxes.
Extract JSON guide
Working walkthrough with filtering and pipeline examples.
ToJson()
Full API reference for
ToJson().Tables guide
Best practices for extracting tables with layout data and converting to DataTables or CSV.