BeginTagA

Tagged PDF, Accessibility

Description

The trailing A denotes the ANSI (char) DLL entry point; the ActiveX/COM surface exposes only the Unicode form. Behaviour is identical to BeginTag and string arguments are interpreted using the current SetAnsiMode code page

Opens a tagged-PDF structure element on the current page. Writes a BDC (Begin Marked Content with Dictionary) operator to the content stream and registers the element in the document's logical structure tree. The structure tree is finalized automatically when the document is saved.

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

Syntax

Delphi

Function DLBeginTagA(InstanceID: Integer; TagType, AltText, ActualText: PAnsiChar): Integer;

DLL

int DLBeginTagA(int InstanceID, const char * TagType, const char * AltText, const char * ActualText);

Parameters

TagTypePDF standard structure type: P, H1–H6, 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 (maps to the PDF /Alt attribute). Pass an empty string if not required.
ActualTextReplacement text for content whose visual representation differs from its logical meaning (maps to the PDF /ActualText attribute). Pass an empty string if not required.

Return values

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

Example

// Heading, then a paragraph
PDF.SetPDFUAMode('en-US');
PDF.BeginTag('H1', '', '');
PDF.PrintText(50, 750, 'Introduction');
PDF.EndTag;
PDF.BeginTag('P', '', '');
PDF.PrintText(50, 730, 'This document demonstrates tagged PDF.');
PDF.EndTag;

// Figure with alt text
PDF.BeginTag('Figure', 'Company logo', '');
PDF.DrawImage(50, 650, 120, 60, 'logo.png');
PDF.EndTag;

Remarks

Use BeginArtifact/EndArtifact for decorative content (page headers, footers, background elements) that should not be read by screen readers.

The document must be in write mode (created or opened for modification). Call SetPDFUAMode before tagging to satisfy PDF/UA-1 requirements.