Overview
By default, PDF4LLM processes every page in a document. Thepages parameter lets you specify exactly which pages to extract — as a List<int> of zero-based page indices. It is supported by ToMarkdown(), ToJson(), and ToText().
Zero-based indexing
Page numbers in PDF4LLM are zero-based — the first page of a document is page0, the second is page 1, and so on.
Common patterns
First N pages
Last N pages
A specific range
Non-contiguous pages
Every other page
Getting the page count
Open aDocument to inspect the page count before building your pages list:
Page selection with per-page chunks
When usingLlamaMarkdownReader, the returned list will only contain chunks for the pages you specify if you pre-filter the results. Each chunk’s ExtraInfo preserves the original page number from the document:
Page selection with ToJson() and ToText()
Thepages parameter works identically across all three extraction methods:
Processing a document in batches
For very large documents, process pages in batches to manage memory usage:Skipping blank or cover pages
Combine page selection with a quick content check to skip pages that return no meaningful text:The
pages parameter is supported by ToMarkdown(), ToJson(), and ToText(). For full API signatures see the API reference.Next steps
Saving Output
Write extracted pages to .md, .json, and .txt files.
Extract Markdown
Full walkthrough of ToMarkdown() with all common options.
Extract JSON
Bounding boxes and layout data for custom pipelines.
OCR
Process scanned pages with Tesseract OCR.