BeginTagEx

Tagged PDF, Accessibility

Description

Opens a tagged-PDF structure element on the current page, with an explicit natural-language attribute. Identical to BeginTag but adds a Lang parameter that is written to the structure element's /Lang attribute.

Use this function for content whose language differs from the document's default language (set by SetPDFUAMode or SetDocumentLanguage). ISO 14289-1 §7.2 requires the /Lang attribute to be set on any text segment that is not in the document's primary language.

Tags must be balanced: every BeginTagEx call must be followed by a matching EndTag call. Tags can be nested.

Syntax

Delphi

function TPDFlib.BeginTagEx(const TagType, AltText, ActualText, Lang: WideString): Integer;

ActiveX

Function PDFlib::BeginTagEx(TagType As String, AltText As String, ActualText As String, Lang As String) As Long

DLL

int DLBeginTagEx(int InstanceID, wchar_t* TagType, wchar_t* AltText, wchar_t* ActualText, wchar_t* Lang);
int DLBeginTagExA(int InstanceID, char* TagType, char* AltText, char* ActualText, char* Lang);

Parameters

TagTypePDF standard structure type: P, H1H6, Figure, Table, TR, TH, TD, L, LI, LBody, Span, Link, Note, etc. (see ISO 32000-1 §14.8.4).
AltTextAlternative text for images and other non-text content (/Alt attribute). Pass an empty string if not required.
ActualTextReplacement text for content whose visual form differs from its logical meaning (/ActualText attribute). Pass an empty string if not required.
LangBCP 47 language tag for the content in this element, e.g. en-US, fr-FR, zh-Hans. Pass an empty string to inherit the document language. When non-empty, it overrides the document-level language for this element and all its descendants.

Return values

0Failed (no document is open)
1Tag opened successfully

Example

// Document in English with a French citation
PDF.SetPDFUAMode('en-US');
PDF.BeginTag('P', '', '');
PDF.PrintText(50, 750, 'The French motto is:');
PDF.EndTag;
PDF.BeginTagEx('Span', '', '', 'fr-FR');
PDF.PrintText(50, 730, 'Liberté, Égalité, Fraternité');
PDF.EndTag;