API Reference
API reference for the liteparse Rust crate. Types are shared across Node.js, Python, and WASM bindings.
LiteParse — open-source PDF parsing with spatial text extraction, OCR, and bounding boxes.
This crate is the core Rust library. Language bindings for Node.js, Python, and WebAssembly re-export the same types with language-idiomatic wrappers.
Struct LiteParseConfig
Section titled “Struct LiteParseConfig”Configuration for LiteParse document parsing.
pub struct LiteParseConfig { pub ocr_language: String, pub ocr_enabled: bool, pub ocr_server_url: Option<String>, pub ocr_server_headers: Vec<(String, String)>, pub tessdata_path: Option<String>, pub max_pages: usize, pub target_pages: Option<String>, pub dpi: f32, pub output_format: OutputFormat, pub preserve_very_small_text: bool, pub password: Option<String>, pub quiet: bool, pub num_workers: usize, pub image_mode: ImageMode, pub extract_images: bool, pub image_output_dir: Option<String>, pub extract_links: bool, pub keep_headers_footers: bool, pub extract_annotations: bool, pub extract_form_fields: bool, pub extract_structure_tree: bool, pub extract_content_bounds: bool, pub extract_xfa_packets: bool, pub detect_screenshot_rects: bool, pub render_form_fields: bool, pub ocr_failure_fatal: bool, pub ocr_hedge_delays_ms: Vec<u64>, pub emit_word_boxes: bool, pub extract_text_metadata: bool, pub crop_box: Option<CropBox>, pub skip_diagonal_text: bool, pub include_complexity: bool, pub extract_vector_graphics: bool,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
ocr_language | String | OCR language code (Tesseract format: “eng”, “fra”, “deu”, etc.). |
ocr_enabled | bool | Whether OCR is enabled. When true, runs on text-sparse pages and embedded images. |
ocr_server_url | Option<String> | HTTP OCR server URL (uses Tesseract if not provided) |
ocr_server_headers | Vec<(String, String)> | Extra HTTP headers sent with every request to ocr_server_url, as(name, value) pairs. Use for auth, e.g. ("Authorization", "Bearer …").Ignored when ocr_server_url is None. |
tessdata_path | Option<String> | Path to tessdata directory. Falls back to TESSDATA_PREFIX env var if not set. |
max_pages | usize | Maximum number of pages to parse. |
target_pages | Option<String> | Specific pages to parse (e.g., “1-5,10,15-20”). None means all pages. |
dpi | f32 | DPI for rendering pages (used for OCR and screenshots). |
output_format | OutputFormat | Output format. |
preserve_very_small_text | bool | Keep very small text that would normally be filtered out. |
password | Option<String> | Password for encrypted/protected documents. |
quiet | bool | Suppress progress output. |
num_workers | usize | Number of concurrent OCR workers. Defaults to (number of CPU cores - 1), minimum 1. |
image_mode | ImageMode | Controls how raster image references are surfaced in markdown output. This does not enable embedded-image extraction. |
extract_images | bool | Extract embedded image bytes and metadata into ParseResult.images.Defaults to false. ImageMode::Embed also enables extraction forbackwards compatibility (see [ LiteParseConfig::effective_extract_images]). |
image_output_dir | Option<String> | Directory where extracted embedded images are written. Requiresextract_images to be true. |
extract_links | bool | Extract hyperlink annotations and render them as [text](url) inmarkdown output. Default on. Disable for benchmark parity with plain-text ground truth (the GT corpora never use link syntax). |
keep_headers_footers | bool | Keep running header/footer chrome in markdown output instead of stripping it. By default the markdown renderer removes lines that repeat in the top/bottom page bands across pages (and single-page chrome like Page N of M). Set true to retain everything —useful for extraction pipelines that would rather deduplicate downstream than risk losing content. Only affects Markdown output. |
extract_annotations | bool | Extract all PDF annotations into each parsed page. Default false.This is independent of extract_links, which only controls Markdownlink reconstruction. |
extract_form_fields | bool | Extract AcroForm widget fields and values. Default false. |
extract_structure_tree | bool | Extract the tagged-PDF logical structure tree. Default false. |
extract_content_bounds | bool | Emit each page’s content_bounds: the union bbox of its top-levelcontent objects in viewport coords (visible content extent). Default false to keep the default output shape unchanged. Content bounds arestill computed internally for the white-fill heuristic whenever extract_vector_graphics is on. |
extract_xfa_packets | bool | Extract raw XFA packets (name + XML content) from XFA form documents into ParseResult.xfa_packets. Default false. Non-XFA documentsyield an empty list. |
detect_screenshot_rects | bool | Detect solid rectangles and thick lines in rendered page screenshots and attach them to each ScreenshotResult.rects. Works on the raster,so it also finds structure in scanned/flattened pages that have no vector paths. Default false (adds a full-bitmap scan per page). |
render_form_fields | bool | Draw AcroForm field appearances (filled values, checkbox states) into rendered rasters (screenshots and OCR inputs). This initializes a PDFium form-fill environment and runs the document’s open/JS actions, so it is off by default: plain parses should neither execute document scripts nor change raster bytes for form-bearing PDFs. |
ocr_failure_fatal | bool | Whether a systemic OCR failure (every OCR task failed and at least one was a text-sparse page whose primary text source was OCR) aborts the whole parse. Default true: surface the root cause instead of silentlyemitting blank pages. Set false to keep already-recovered native textand return partial results when OCR is unavailable — useful for callers that prefer a degraded document over a hard failure (e.g. when the host has its own OCR fallback or treats OCR as best-effort enrichment). |
ocr_hedge_delays_ms | Vec<u64> | OCR request-hedging schedule (milliseconds) for the HTTP OCR engine. Empty (default) = no hedging. With multiple delays (e.g. [0, 5000, 10000, 15000, 20000]), each OCR attempt fires a duplicaterequest at every delay and takes the first to succeed — trading extra OCR-server load for lower tail latency on a slow/stuck pod. No effect on the Tesseract engine. |
emit_word_boxes | bool | Emit per-word sub-boxes on each TextItem (TextItem.words). Defaultfalse: a text item already carries its own box, and word boxes roughlydouble the text-item payload (size + napi marshalling), so they are only worth computing for callers doing word-level bbox attribution. When false, TextItem.words is always empty and the per-word tracking isskipped entirely (zero allocation). |
extract_text_metadata | bool | Include rich PDF text metadata on public text items: MCID, glyph width, font metrics/weight/buggy state, fill/stroke colors, raw character codes, and generated-trailing-space state. Default false to preserveLiteParse’s lightweight response shape. Layout-required metrics remain available internally; source character codes and generated-space state are not computed unless this is enabled. |
crop_box | Option<CropBox> | Restrict output to a sub-region of every page. Each field is the fraction of the page to crop away from that side (e.g. left = 0.5discards the left half). A text item is kept only when it lies entirely inside the surviving rectangle [left·W, (1-right)·W] × [top·H, (1-bottom)·H] (top-left origin).None (default) keeps the whole page. Applied after OCR merge, so italso drops OCR-sourced text outside the region. |
skip_diagonal_text | bool | Drop diagonal (skewed) text — items whose rotation is more than 2° off the nearest right angle (0/90/180/270). Default false. |
include_complexity | bool | Compute per-page complexity signals during parse and attach them toeach ParsedPage (surfaced as a complexity object per page in JSON).These are the same signals the standalone is_complex API returns.Default false. |
extract_vector_graphics | bool | Expose page-scoped vector path data (shapes and merged horizontal /vertical lines) in parse results. Default false; path objects arestill inspected internally for layout detection when disabled. |
Methods
Section titled “Methods”-
Whether embedded-image extraction should run. True whenpub fn effective_extract_images(self: &Self) -> bool { /* ... */ }
Struct CropBox
Section titled “Struct CropBox”A page sub-region expressed as the fraction cropped from each side.
All fields are in [0, 1]; left + right < 1 and top + bottom < 1
for a non-empty region. Origin is top-left, matching TextItem coordinates.
pub struct CropBox { pub top: f32, pub right: f32, pub bottom: f32, pub left: f32,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
top | f32 | |
right | f32 | |
bottom | f32 | |
left | f32 |
Enum ImageMode
Section titled “Enum ImageMode”Attributes:
Other("#[serde(rename_all = \"lowercase\")]")
Image handling for the markdown emitter.
Off— strip image references entirely.Placeholder(default) — emitreferences in reading order at each image’s y position, but do not extract or return pixel bytes. Keeps response size small while letting the LLM see where figures live in the document.Embed— emit the same references asPlaceholder, and extract the embedded pixel bytes intoParseResult.images(equivalent to settingLiteParseConfig::extract_images).
pub enum ImageMode { Off, Placeholder, Embed,}Variants
Section titled “Variants”Placeholder
Section titled “Placeholder”Enum OutputFormat
Section titled “Enum OutputFormat”Attributes:
Other("#[serde(rename_all = \"lowercase\")]")
Supported output formats.
pub enum OutputFormat { Json, Text, Markdown,}Variants
Section titled “Variants”Markdown
Section titled “Markdown”Enum LiteParseError
Section titled “Enum LiteParseError”pub enum LiteParseError { Pdf(pdfium::PdfiumError), Io(std::io::Error), Json(serde_json::Error), Image(image::ImageError), Ocr(String), Conversion(String), Config(String), Other(String),}Variants
Section titled “Variants”Pdf(pdfium::PdfiumError)
Section titled “Pdf(pdfium::PdfiumError)”Io(std::io::Error)
Section titled “Io(std::io::Error)”Json(serde_json::Error)
Section titled “Json(serde_json::Error)”Image(image::ImageError)
Section titled “Image(image::ImageError)”Ocr(String)
Section titled “Ocr(String)”Conversion(String)
Section titled “Conversion(String)”Config(String)
Section titled “Config(String)”Other(String)
Section titled “Other(String)”Module glyph_resolver
Section titled “Module glyph_resolver”Optional out-of-tree glyph recovery hook.
liteparse’s built-in recovery for fonts with missing/garbage /ToUnicode
(PostScript glyph-name → Adobe Glyph List, then the embedded font program’s
reverse cmap; see [crate::extract]) is deterministic but cannot decode
buggy/obfuscated fonts whose glyph names and cmap are also junk. A
[GlyphResolver] lets a caller plug in a richer recovery strategy — e.g. a
glyph-outline → unicode database — without liteparse taking on that
dependency.
The resolver is supplied the glyph’s vector outline (path segments), not a pdfium handle, so the implementation needs no pdfium of its own and stays decoupled from liteparse’s font internals. It is consulted only as a last resort, after the built-in recovery has failed on a glyph liteparse already considers untrusted.
pub mod glyph_resolver { /* ... */ }Traits
Section titled “Traits”Trait GlyphResolver
Section titled “Trait GlyphResolver”Recovers the unicode text for a glyph liteparse’s built-in cmap/AGL recovery could not decode, from the glyph’s vector outline.
Implementations live out-of-tree (the published @llamaindex/liteparse
ships no resolver). Inject one with [crate::LiteParse::with_glyph_resolver].
pub trait GlyphResolver: Send + Sync { /* Associated items */}Required Items
Section titled “Required Items”Required Methods
Section titled “Required Methods”resolve: Resolve a glyph from its outline.
Constants and Statics
Section titled “Constants and Statics”Constant GLYPH_RESOLVER_FONT_SIZE
Section titled “Constant GLYPH_RESOLVER_FONT_SIZE”Font size, in points, at which glyph path segments are sampled before being
handed to a [GlyphResolver].
Resolvers that key on a hash of the outline must sample at this exact size for their keys to line up.
pub const GLYPH_RESOLVER_FONT_SIZE: f32 = 10.0;Struct ParseResult
Section titled “Struct ParseResult”Result of parsing a document.
pub struct ParseResult { pub pages: Vec<crate::types::ParsedPage>, pub text: String, pub outline: Vec<crate::types::OutlineTarget>, pub images: Vec<crate::types::ExtractedImage>, pub image_error_count: u32, pub form_type: Option<i32>, pub creator: Option<String>, pub producer: Option<String>, pub xfa_packets: Option<Vec<crate::types::XfaPacket>>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
pages | Vec<crate::types::ParsedPage> | Parsed pages with projected text layout. |
text | String | Full document text, concatenated from all pages. |
outline | Vec<crate::types::OutlineTarget> | Document outline (bookmarks) when present. Used by the markdown emitter as a high-priority heading source on untagged PDFs. |
images | Vec<crate::types::ExtractedImage> | Raster images extracted from the document. Empty unless the parser was configured with extract_images. Each entry carries the sameid and format the markdown emitter referenced, so the caller canmatch them up without parsing markdown. |
image_error_count | u32 | Number of embedded image objects that could not be extracted. A bad image does not fail the rest of the document parse. |
form_type | Option<i32> | PDFium form type (0 none, 1 AcroForm, 2 XFA full, 3 XFA foreground), present only when form-field extraction is enabled. |
creator | Option<String> | The document’s /Info Creator entry, when present. |
producer | Option<String> | The document’s /Info Producer entry, when present. |
xfa_packets | Option<Vec<crate::types::XfaPacket>> | Raw XFA packets, present only when extract_xfa_packets is enabled.Some([]) means extraction ran on a non-XFA document. |
Struct ScreenshotResult
Section titled “Struct ScreenshotResult”Result of rendering a single page screenshot.
pub struct ScreenshotResult { pub page_num: u32, pub width: u32, pub height: u32, pub image_bytes: Vec<u8>, pub is_solid_fill: bool, pub rects: Vec<crate::types::ScreenshotRect>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
page_num | u32 | |
width | u32 | |
height | u32 | |
image_bytes | Vec<u8> | |
is_solid_fill | bool | True when every pixel has the same color (blank page after render). |
rects | Vec<crate::types::ScreenshotRect> | Solid rectangles/lines detected in the raster (viewport coords). Populated only when LiteParseConfig::detect_screenshot_rects is on. |
Struct LiteParse
Section titled “Struct LiteParse”Main LiteParse orchestrator.
Thread safety
Section titled “Thread safety”LiteParse is Send + Sync and safe to share across threads (e.g.
behind an Arc, or used concurrently from a multi-threaded tokio
runtime).
PDFium itself is not thread-safe, so all PDFium FFI work — document
loading, page rendering, text extraction — is serialized through a
process-global lock held by [pdfium::Library]. From a caller’s
perspective, this means concurrent parse_* / screenshot* calls are
safe but their PDFium portions run sequentially. The OCR pass and grid
projection (which dominate runtime for OCR-heavy documents) run outside
the lock and remain fully concurrent.
pub struct LiteParse { // Some fields omitted}Methods
Section titled “Methods”-
pub fn new(config: LiteParseConfig) -> Self { /* ... */ }
-
pub fn with_ocr_engine(self: Self, engine: std::sync::Arc<dyn OcrEngine>) -> Self { /* ... */ }
Override the OCR engine. When set, the engine is used regardless of
-
pub fn with_glyph_resolver(self: Self, resolver: std::sync::Arc<dyn crate::GlyphResolver>) -> Self { /* ... */ }
Inject a glyph recovery hook. When set, glyphs that liteparse considers
-
pub async fn is_complex(self: &Self, input: PdfInput) -> Result<Vec<ocr_merge::PageComplexityStats>, LiteParseError> { /* ... */ }
Determine the complexity of each page in a document, returning a vector
-
pub async fn parse(self: &Self, input: &str) -> Result<ParseResult, LiteParseError> { /* ... */ }
Parse a document from a file path, returning structured results.
-
pub async fn parse_input(self: &Self, input: PdfInput) -> Result<ParseResult, LiteParseError> { /* ... */ }
Parse a document from either a file path or raw bytes.
-
pub fn parse_from_pages(self: &Self, pages: Vec<Page>, outline: Vec<OutlineTarget>) -> ParseResult { /* ... */ }
Parse from pre-extracted pages, skipping PDFium text extraction.
-
pub async fn screenshot(self: &Self, input: &str, page_numbers: Option<Vec<u32>>) -> Result<Vec<ScreenshotResult>, LiteParseError> { /* ... */ }
Generate screenshots of document pages as PNG bytes.
-
pub async fn screenshot_input(self: &Self, input: PdfInput, page_numbers: Option<Vec<u32>>) -> Result<Vec<ScreenshotResult>, LiteParseError> { /* ... */ }
Generate screenshots from a file path or raw bytes.
-
pub fn config(self: &Self) -> &LiteParseConfig { /* ... */ }
Struct SearchOptions
Section titled “Struct SearchOptions”Options for searching text items.
pub struct SearchOptions { pub phrase: String, pub case_sensitive: bool,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
phrase | String | |
case_sensitive | bool |
Function search_items
Section titled “Function search_items”Search text items for phrase matches, returning synthetic merged items.
Consecutive text items are concatenated and searched. When a phrase spans multiple items, the result is a single merged item with a combined bounding box and the matched text. Font metadata is taken from the first matched item.
pub fn search_items(items: &[crate::types::TextItem], options: &SearchOptions) -> Vec<crate::types::TextItem> { /* ... */ }Struct TextItem
Section titled “Struct TextItem”Represents a single text item extracted from a PDF page, including its content, position, size, rotation, and font metadata.
pub struct TextItem { pub text: String, pub x: f32, pub y: f32, pub width: f32, pub height: f32, pub rotation: f32, pub font_name: Option<String>, pub font_size: Option<f32>, pub font_height: Option<f32>, pub font_ascent: Option<f32>, pub font_descent: Option<f32>, pub font_weight: Option<i32>, pub font_flags: Option<i32>, pub text_width: Option<f32>, pub font_is_buggy: bool, pub has_unicode_map_error: bool, pub mcid: Option<i32>, pub fill_color: Option<String>, pub stroke_color: Option<String>, pub char_codes: Vec<u32>, pub trailing_space_generated: bool, pub confidence: Option<f32>, pub link: Option<String>, pub strike: bool, pub words: Vec<WordBox>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
text | String | |
x | f32 | Viewport-space coordinates (top-left origin, 72 DPI). |
y | f32 | |
width | f32 | |
height | f32 | |
rotation | f32 | Rotation in degrees (counter-clockwise, adjusted for page rotation). |
font_name | Option<String> | |
font_size | Option<f32> | |
font_height | Option<f32> | Font size * scale_y from the text matrix — accounts for CTM scaling. |
font_ascent | Option<f32> | |
font_descent | Option<f32> | |
font_weight | Option<i32> | |
font_flags | Option<i32> | |
text_width | Option<f32> | Sum of glyph widths (using charcode-based lookup when possible). |
font_is_buggy | bool | Whether the font has buggy encoding (private-use codepoints, TT subset, etc.) |
has_unicode_map_error | bool | Whether most characters in this item could not be mapped to Unicode (e.g. a Type3 font with no ToUnicode map). The text content is PDFium’s char-code fallback and does not reflect the rendered glyphs. |
mcid | Option<i32> | Marked content ID from the PDF structure tree. |
fill_color | Option<String> | Fill color as ARGB hex string (e.g. “ff000000”). |
stroke_color | Option<String> | Stroke color as ARGB hex string. |
char_codes | Vec<u32> | Raw character codes from the PDF content stream. These correspond to source glyphs rather than Unicode scalar values, so ligature expansion can produce more text characters than entries in this array. |
trailing_space_generated | bool | Whether the trailing source space was synthesized by PDFium rather than represented by a real space glyph in the PDF content stream. |
confidence | Option<f32> | OCR confidence score (0.0–1.0). None for native PDF text. |
link | Option<String> | Target URI when this item falls inside a hyperlink annotation’s rectangle. Populated in extract.rs; consumed by the markdown emitter. |
strike | bool | Whether a thin horizontal stroke/rect crosses this item’s vertical middle band (a strikethrough line). Populated in extract.rs; consumed by themarkdown emitter to wrap the text in ~~…~~. |
words | Vec<WordBox> | Per-word sub-boxes within this item, split on the inter-word spaces seen during segment building. A segment groups several words together (it only breaks at line/column boundaries), so this exposes the finer word-level geometry needed for bbox attribution. Empty for items that produced no word split (e.g. OCR-sourced or single-token items). Internal/attribution use only — #[serde(skip)] keeps it out of the JSON output but it ismarshalled across the napi boundary. |
Methods
Section titled “Methods”-
The rich-metadata view of this item: real values whenpub fn text_metadata(self: &Self, enabled: bool) -> TextMetadata<''_> { /* ... */ }
enabled, all
Struct TextMetadata
Section titled “Struct TextMetadata”The TextItem fields governed by extract_text_metadata, pre-gated by
[TextItem::text_metadata]. This struct defines which fields count as
rich text metadata: every output surface (CLI JSON, napi, python, wasm)
builds its public items from it, so a new metadata field added here is a
compile error in each surface until it is wired through.
All fields are Option/slice so “extraction disabled” is representable
even for the plain-bool fields on TextItem: None/empty means the
caller did not opt in and the field must be omitted from output.
pub struct TextMetadata<''a> { pub font_height: Option<f32>, pub font_ascent: Option<f32>, pub font_descent: Option<f32>, pub font_weight: Option<i32>, pub text_width: Option<f32>, pub font_is_buggy: Option<bool>, pub mcid: Option<i32>, pub fill_color: Option<&''a str>, pub stroke_color: Option<&''a str>, pub char_codes: Option<&''a [u32]>, pub trailing_space_generated: Option<bool>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
font_height | Option<f32> | |
font_ascent | Option<f32> | |
font_descent | Option<f32> | |
font_weight | Option<i32> | |
text_width | Option<f32> | |
font_is_buggy | Option<bool> | |
mcid | Option<i32> | |
fill_color | Option<&''a str> | |
stroke_color | Option<&''a str> | |
char_codes | Option<&''a [u32]> | |
trailing_space_generated | Option<bool> |
Struct WordBox
Section titled “Struct WordBox”One word’s bounding box within a TextItem, in the same viewport space
(top-left origin, 72 DPI) as the parent item. text is the word’s content
with inter-word spaces excluded.
pub struct WordBox { pub text: String, pub x: f32, pub y: f32, pub width: f32, pub height: f32,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
text | String | |
x | f32 | |
y | f32 | |
width | f32 | |
height | f32 |
Struct DocumentAnnotation
Section titled “Struct DocumentAnnotation”One PDF page annotation. Coordinates use the same top-left, 72-DPI
viewport space as [TextItem].
pub struct DocumentAnnotation { pub subtype: String, pub contents: Option<String>, pub created: Option<String>, pub modified: Option<String>, pub title: Option<String>, pub rect: Option<Rect>, pub quadpoint_rects: Vec<Rect>, pub uri: Option<String>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
subtype | String | |
contents | Option<String> | |
created | Option<String> | |
modified | Option<String> | |
title | Option<String> | |
rect | Option<Rect> | |
quadpoint_rects | Vec<Rect> | |
uri | Option<String> |
Enum StructureAttributeValue
Section titled “Enum StructureAttributeValue”Attributes:
Other("#[serde(untagged)]")
Scalar value from a tagged-PDF structure element’s /A dictionary.
pub enum StructureAttributeValue { Boolean(bool), Number(f32), String(String),}Variants
Section titled “Variants”Boolean(bool)
Section titled “Boolean(bool)”Number(f32)
Section titled “Number(f32)”String(String)
Section titled “String(String)”Struct StructureTree
Section titled “Struct StructureTree”A complete page-scoped tagged-PDF logical structure tree.
pub struct StructureTree { pub roots: Vec<StructureTreeElement>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
roots | Vec<StructureTreeElement> |
Struct StructureTreeElement
Section titled “Struct StructureTreeElement”One tagged-PDF structure element. Field names follow the repository’s snake_case JSON convention rather than PDFium’s C spellings.
pub struct StructureTreeElement { pub element_type: String, pub id: Option<String>, pub actual_text: Option<String>, pub alt_text: Option<String>, pub title: Option<String>, pub attributes: std::collections::BTreeMap<String, StructureAttributeValue>, pub marked_content_ids: Vec<i32>, pub children: Vec<StructureTreeElement>, pub annotations: Vec<DocumentAnnotation>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
element_type | String | |
id | Option<String> | |
actual_text | Option<String> | |
alt_text | Option<String> | |
title | Option<String> | |
attributes | std::collections::BTreeMap<String, StructureAttributeValue> | |
marked_content_ids | Vec<i32> | |
children | Vec<StructureTreeElement> | |
annotations | Vec<DocumentAnnotation> |
Struct FormField
Section titled “Struct FormField”One AcroForm widget and its resolved field metadata.
pub struct FormField { pub id: String, pub field_type: String, pub page: u32, pub annotation_index: i32, pub widget_index: i32, pub object_number: Option<i32>, pub name: Option<String>, pub alternate_name: Option<String>, pub value: Option<String>, pub export_value: Option<String>, pub field_flags: i32, pub control_count: Option<i32>, pub control_index: Option<i32>, pub checked: Option<bool>, pub rect: Option<Rect>, pub options: Vec<String>, pub selected_options: Vec<String>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
id | String | |
field_type | String | |
page | u32 | |
annotation_index | i32 | |
widget_index | i32 | |
object_number | Option<i32> | |
name | Option<String> | |
alternate_name | Option<String> | |
value | Option<String> | |
export_value | Option<String> | |
field_flags | i32 | |
control_count | Option<i32> | |
control_index | Option<i32> | |
checked | Option<bool> | |
rect | Option<Rect> | |
options | Vec<String> | |
selected_options | Vec<String> |
Struct XfaPacket
Section titled “Struct XfaPacket”One raw packet from an XFA form document’s /XFA array. Surfaced on
ParseResult.xfa_packets when extract_xfa_packets is enabled.
pub struct XfaPacket { pub index: u32, pub name: Option<String>, pub content_length: u32, pub content: Option<String>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
index | u32 | Zero-based index in the XFA array. |
name | Option<String> | Packet name (e.g. template, datasets), when present. |
content_length | u32 | Decoded content length in bytes. |
content | Option<String> | Packet content (usually XML), lossily decoded as UTF-8. None whenthe packet stream could not be read. |
Struct ScreenshotRect
Section titled “Struct ScreenshotRect”One solid rectangle (or thick line) detected in a rendered page bitmap. Coordinates are in the same top-left, 72-DPI viewport space as text items. Detection runs on the raster, so it also covers scanned/flattened pages that carry no vector paths.
pub struct ScreenshotRect { pub x: f32, pub y: f32, pub width: f32, pub height: f32, pub color: String, pub is_line: bool,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
x | f32 | |
y | f32 | |
width | f32 | |
height | f32 | |
color | String | Fill color as ARGB hex string (e.g. “ff1a2b3c”). |
is_line | bool | True when only one dimension reaches the minimum rectangle size (a solid line rather than a filled area). |
Struct ParsedPage
Section titled “Struct ParsedPage”Represents a fully parsed page with projected text layout.
pub struct ParsedPage { pub page_number: usize, pub page_width: f32, pub page_height: f32, pub content_bounds: Option<Rect>, pub text: String, pub markdown: String, pub text_items: Vec<TextItem>, pub projected_lines: Vec<ProjectedLine>, pub regions: Region, pub graphics: Vec<GraphicPrimitive>, pub vector_graphics: Option<VectorGraphics>, pub figures: Vec<Rect>, pub struct_nodes: Vec<StructNode>, pub image_refs: Vec<ImageRef>, pub complexity: Option<crate::ocr_merge::PageComplexityStats>, pub annotations: Option<Vec<DocumentAnnotation>>, pub form_fields: Option<Vec<FormField>>, pub structure_tree: Option<StructureTree>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
page_number | usize | |
page_width | f32 | |
page_height | f32 | |
content_bounds | Option<Rect> | Union bbox of the page’s top-level content objects in viewport coords (visible content extent). None for empty pages. |
text | String | |
markdown | String | |
text_items | Vec<TextItem> | |
projected_lines | Vec<ProjectedLine> | Per-line structural metadata used by the markdown emitter. Not part of the JSON/text outputs (consumed internally) so it is #[serde(skip)]. |
regions | Region | Root of the XY-cut region tree for this page. Leaves correspond to theregion_path on each ProjectedLine. Internal-only. |
graphics | Vec<GraphicPrimitive> | Vector graphics on the page (decomposed paths) used by the markdown emitter for ruled-table / HR / figure-cluster detection. Not part of the JSON/text output. |
vector_graphics | Option<VectorGraphics> | Public vector path extraction. Absent unless explicitly enabled. |
figures | Vec<Rect> | Figure-region bounding rectangles derived from graphics. Pre-computedin to_parsed_pages so the XY-cut layout pass can treat them asobstacles, and reused downstream for figure classification. |
struct_nodes | Vec<StructNode> | Structure-tree nodes for this page (tagged PDFs only). Pre-flattened in pre-order. Consumed by the markdown classifier for highest-priority heading / figure / table detection. |
image_refs | Vec<ImageRef> | Raster image objects on the page. Bbox in viewport coords. Populated during extraction; consumed by the markdown emitter to interleave Block::Figure references at the right y position. Empty when thepage has no embedded images. Not part of JSON/text output. |
complexity | Option<crate::ocr_merge::PageComplexityStats> | Per-page complexity signals (the same the is_complex API returns).Populated only when LiteParseConfig::include_complexity is set;None otherwise. Surfaced as a per-page complexity object in JSON. |
annotations | Option<Vec<DocumentAnnotation>> | Page annotations when LiteParseConfig::extract_annotations is true.None means extraction was disabled; Some([]) means enabled with noannotations on this page. |
form_fields | Option<Vec<FormField>> | AcroForm widgets when extract_form_fields is true. |
structure_tree | Option<StructureTree> | Tagged-PDF logical structure when extract_structure_tree is true. |
Struct ExtractedImage
Section titled “Struct ExtractedImage”A raster image extracted from a page along with its pixel bytes. Surfaced
on ParseResult.images only when extract_images is enabled; otherwise
the extraction step skips the render and only ImageRefs are
produced. JPEG streams are preserved without re-encoding when PDFium
exposes a valid directly decoded DCT stream; other images are encoded as
PNG from PDFium’s rendered bitmap.
pub struct ExtractedImage { pub id: String, pub name: String, pub path: Option<String>, pub page: u32, pub bbox: Rect, pub width: u32, pub height: u32, pub rotation: f32, pub format: String, pub duplicate_of: Option<String>, pub bytes: std::sync::Arc<Vec<u8>>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
id | String | |
name | String | |
path | Option<String> | |
page | u32 | |
bbox | Rect | |
width | u32 | |
height | u32 | |
rotation | f32 | |
format | String | |
duplicate_of | Option<String> | |
bytes | std::sync::Arc<Vec<u8>> | Encoded image bytes. Shared (Arc) so duplicate entries reference thecanonical image’s buffer instead of copying it per occurrence. |
Struct VectorGraphics
Section titled “Struct VectorGraphics”Page-scoped vector path output. Coordinates use the same top-left, 72-DPI viewport space as text items.
pub struct VectorGraphics { pub shapes: Vec<VectorShape>, pub lines: Vec<VectorLine>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
shapes | Vec<VectorShape> | |
lines | Vec<VectorLine> |
Struct VectorShape
Section titled “Struct VectorShape”One PDF path object’s paint state and viewport bounding box.
pub struct VectorShape { pub bbox: Rect, pub stroke: bool, pub stroke_color: Option<String>, pub fill: bool, pub fill_color: Option<String>, pub has_curve: bool,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
bbox | Rect | |
stroke | bool | |
stroke_color | Option<String> | |
fill | bool | |
fill_color | Option<String> | |
has_curve | bool |
Struct VectorLine
Section titled “Struct VectorLine”A strict horizontal or vertical path segment after adjacent compatible segments have been merged, matching LlamaParse PDFium path semantics.
pub struct VectorLine { pub x1: f32, pub y1: f32, pub x2: f32, pub y2: f32, pub stroke: bool, pub stroke_width: Option<f32>, pub stroke_color: Option<String>, pub fill: bool, pub fill_color: Option<String>,}Fields
Section titled “Fields”| Name | Type | Documentation |
|---|---|---|
x1 | f32 | |
y1 | f32 | |
x2 | f32 | |
y2 | f32 | |
stroke | bool | |
stroke_width | Option<f32> | |
stroke_color | Option<String> | |
fill | bool | |
fill_color | Option<String> |