BeginMarkedContent

Tagged PDF, Accessibility

Description

Opens a marked content range in the current content stream by writing a BDC (Begin Marked Content with Property List) operator. This is typically used to create structured (Tagged) PDFs, satisfying accessibility requirements (such as PDF/UA)

BeginMarkedContent must be closed with a corresponding call to EndMarkedContent. Marked content ranges can be nested

Syntax

Delphi

Function TPDFlib.BeginMarkedContent(Const TagType, AltText, ActualText, Lang, Expansion: WideString): Integer;

Parameters

TagTypeThe structural tag name written without its leading slash, e.g., Span, P, Figure, etc. The library adds the slash when it emits the operator
AltTextAlternative description text for accessibility (maps to the /Alt key in the property list). Pass an empty string if not needed.
ActualTextActual text that replaces the glyph representation for screen readers (maps to the /ActualText key). Pass an empty string if not needed.
LangThe natural language code for the marked content (e.g., en-US, maps to the /Lang key). Pass an empty string if not needed.
ExpansionThe expansion text for abbreviations or acronyms (maps to the /E key). Pass an empty string if not needed.

Return values

0No document is open or failed to write marked content.
1Marked content range opened successfully.

Remarks

To build compliant Tagged PDF/UA files, ensure that logical structure tags enclose all visible text and graphics. This function offers fine-grained property mapping compared to BeginTag

Example

// Heading, then a paragraph with marked content span
PDF.NewDocument;
PDF.NewPage;
PDF.BeginMarkedContent('Span', 'Logo description', '', 'en-US', '');
// Draw graphics or print text here
PDF.EndMarkedContent;

See also

EndMarkedContent, BeginTag, EndTag