ExportPageMarkdown

Text, extraction, Markdown

Description

Exports one PDF page as semantic Markdown using the page's detected paragraphs, lists, headings, and tables

Syntax

Delphi

Function TPDFlib.ExportPageMarkdown(Page, Options: Integer): WideString;

ActiveX

Function PDFlib::ExportPageMarkdown(Page As Long, Options As Long) As String

DLL

const wchar_t* DLExportPageMarkdown(int InstanceID, int Page, int Options);
const char* DLExportPageMarkdownA(int InstanceID, int Page, int Options);

Parameters

PageThe one-based page number
OptionsCombine PDF_MARKDOWN_INCLUDE_PAGE_MARKERS (1), PDF_MARKDOWN_DETECT_HEADINGS (2), and PDF_MARKDOWN_PRESERVE_STYLES (4), or use PDF_MARKDOWN_DEFAULT (7); zero emits semantic blocks without optional markers, heading inference, or font styling

Return values

Returns Markdown text, or an empty string when validation or extraction fails

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

Simple unmerged tables use pipe syntax; tables with merged cells use embedded HTML with row and column spans, preserving empty cells

Heading inference compares short single-line paragraphs with the page's median body text size and produces levels H1 through H3

Font styling recognises bold and italic font names plus superscript and subscript alignment when PDF_MARKDOWN_PRESERVE_STYLES is enabled

Markdown syntax characters are escaped and pipe-table cells escape embedded pipe characters

Extraction preserves the selected page and open writer tag stack; current unsaved writer tags are included without closing tags or finalising the document

DLL return pointers remain valid until the next string-returning call on the same instance

LastErrorCode is 113 for an invalid page or option mask and 517 when extraction fails

See also

ExportDocumentMarkdown, ExtractStructuredPage, ExportPageHTML