AddTagAttribute

Tagged PDF, Accessibility

Description

Adds a named attribute to the structure element currently being built on the tag stack. The attribute is written as a PDF /A attribute dictionary (or array of dictionaries) when the document is saved. Call this after BeginTag or BeginTagEx and before EndTag.

Syntax

Delphi

function TPDFlib.AddTagAttribute(const Owner, Name, Value: WideString): Integer;

ActiveX

Function PDFlib::AddTagAttribute(Owner As String, Name As String, Value As String) As Long

DLL

int DLAddTagAttribute(int InstanceID, wchar_t * Owner, wchar_t * Name, wchar_t * Value);

Parameters

OwnerThe attribute owner name as defined in ISO 32000-1 Table 348 (e.g., Layout, Table, List, PrintField). This becomes the /O key in the attribute dictionary.
NameThe attribute name for the given owner (e.g., BBox for Layout, Scope for Table). Must not be empty.
ValueThe attribute value as a string. Values containing only space-separated numbers (e.g., "0 0 200 100") are written as a PDF array of real numbers. Any other value is written as a PDF name object (without a leading /). Must not be empty.

Return value

Returns 1 on success. Returns 0 if no document is open, no tag is currently open, or Owner or Name is empty.

Remarks

Multiple calls to AddTagAttribute for the same open tag are accumulated. When attributes belong to a single owner, the library writes a single /A attribute dictionary. When multiple owners are used, the attributes are grouped per owner and written as an array of attribute dictionaries.

For common attributes, the convenience wrappers SetStructElemScope and SetStructElemBBox may be used instead of calling AddTagAttribute directly.

Attributes are reset when a new tag is opened; they are not inherited by child elements.

Example

// Mark a table header cell with column scope
PDFlib.BeginTag('TH', '', '', '');
PDFlib.AddTagAttribute('Table', 'Scope', 'Column');
// ... draw cell content ...
PDFlib.EndTag;

// Mark a figure with a bounding box
PDFlib.BeginTag('Figure', 'Company logo', '', '');
PDFlib.AddTagAttribute('Layout', 'BBox', '72 600 200 700');
PDFlib.EndTag;

See also

BeginTag, BeginTagEx, EndTag, SetStructElemScope, SetStructElemBBox