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).
Marked content ranges must be properly balanced: every call to 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;ActiveX
Function PDFlib::BeginMarkedContent(TagType As String, AltText As String, ActualText As String, Lang As String, Expansion As String) As LongDLL
int DLBeginMarkedContent(int InstanceID, const wchar_t * TagType, const wchar_t * AltText, const wchar_t * ActualText, const wchar_t * Lang, const wchar_t * Expansion);Parameters
| TagType | The structural tag name, e.g., /Span, /P, /Figure, etc. |
|---|---|
| AltText | Alternative description text for accessibility (maps to the /Alt key in the property list). Pass an empty string if not needed. |
| ActualText | Actual text that replaces the glyph representation for screen readers (maps to the /ActualText key). Pass an empty string if not needed. |
| Lang | The natural language code for the marked content (e.g., en-US, maps to the /Lang key). Pass an empty string if not needed. |
| Expansion | The expansion text for abbreviations or acronyms (maps to the /E key). Pass an empty string if not needed. |
Return values
| 0 | No document is open or failed to write marked content. |
|---|---|
| 1 | Marked 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.AddPage;
PDF.BeginMarkedContent('/Span', 'Logo description', '', 'en-US', '');
// Draw graphics or print text here
PDF.EndMarkedContent;