ExtractStructuredDocument
Text, extraction, structured data
Description
Captures a selected page range, analyses the pages together, and returns one schema 2 JSON document, one semantic XHTML document or coordinated CSV tables
Syntax
Delphi
Function TPDFlib.ExtractStructuredDocument(Const PageRange: WideString;
Format, Options: Integer): WideString;ActiveX
Function PDFlib::ExtractStructuredDocument(PageRange As String,
Format As Long, Options As Long) As StringDLL
const wchar_t* DLExtractStructuredDocument(int InstanceID,
const wchar_t* PageRange, int Format, int Options);
const char* DLExtractStructuredDocumentA(int InstanceID,
const char* PageRange, int Format, int Options);Parameters
| PageRange | A one-based page range such as 1-3,7, or an empty string for every page |
|---|---|
| Format | PDF_STRUCTURED_TEXT_JSON (0), PDF_STRUCTURED_TEXT_XHTML (1), or PDF_STRUCTURED_TEXT_CSV (2) |
| Options | Zero or PDF_STRUCTURED_TEXT_INCLUDE_STYLES (1) |
Return values
JSON contains version: 2 and a pages array using the schema documented by ExtractStructuredPage; stable semantic node IDs apply across pages
XHTML combines semantic content, with joined table fragments kept inside one table rather than requiring one section per page
CSV contains tables only and is empty when no selected page has one; continued logical tables use one table header and omit identified repeated header rows
An invalid range, format, or option and any extraction failure return an empty string
Remarks
Analysis uses SetStructuredTextOptions independently of the format-specific Options; inspect GetLastStructuredTextDiagnostics for reading sources and fallback warnings
Real tag-tree order takes precedence when content bindings are complete; unresolved or ambiguous content keeps extracted text in mixed or geometric fallback, and unknown custom roles are not guessed from their names
Cross-page analysis identifies repeated margin furniture and compatible table continuations; the default flags identify furniture whilst retaining its text
Tagged cells retain empty content and explicit row and column spans; malformed or overlapping table grids fall back whilst retaining extracted text
Selected page models are retained for document-wide analysis, and the complete serialised result is buffered; memory grows with the selected content and output size
Extraction preserves the selected page and open writer tag stack; current unsaved writer tags are included without closing tags or finalising the document
Progress and cooperative cancellation use the normal document operation lifecycle
LastErrorCode is 111 for invalid input and 515 when extraction fails