THotPDF.AddStructureElement + PDF/UA accessibility attributes

THotPDF tagged-PDF surface (v2.119.36 / v2.119.40 / v2.119.41)

 

AddXFAPacket  AcroForm Support

Adds a structure element to the document's StructTreeRoot for tagged-PDF / PDF/UA-1 (ISO 14289-1) accessibility workflows, including the Table 333 standard structure-type typed overload (v2.119.41), the /Lang + /E + /T attribute setters (v2.119.40), and the §14.8.4 marked-content sequence properties on BeginTaggedContent (v2.119.36).

 

Delphi syntax:

type

  THPDFStandardStructureType = (

    sstDocument, sstPart, sstArt, sstSect, sstDiv, sstBlockQuote,

    sstCaption, sstTOC, sstTOCI, sstIndex, sstNonStruct, sstPrivate,

    sstH, sstH1, sstH2, sstH3, sstH4, sstH5, sstH6, sstP, sstL, sstLI,

    sstLbl, sstLBody, sstTable, sstTR, sstTH, sstTD, sstTHead, sstTBody,

    sstTFoot, sstSpan, sstQuote, sstNote, sstReference, sstBibEntry,

    sstCode, sstLink, sstAnnot, sstRuby, sstWarichu, sstFigure,

    sstFormula, sstForm);  // PDF 1.7 §14.8.4 Table 333 standard types

 

// Typed overload (v2.119.41 - validates against Table 333)

function AddStructureElement(StructureType: THPDFStandardStructureType;

  Parent: THPDFStructureElement): THPDFStructureElement; overload;

 

// String overload (free-form structure-type name + role map)

function AddStructureElement(const StructureTypeName: AnsiString;

  Parent: THPDFStructureElement): THPDFStructureElement; overload;

 

// Structure-element attribute setters (v2.119.40)

procedure SetStructureElementLang(Elem: THPDFStructureElement; const Lang: AnsiString);

procedure SetStructureElementExpansion(Elem: THPDFStructureElement; const E: AnsiString);

procedure SetStructureElementTitle(Elem: THPDFStructureElement; const T: AnsiString);

 

// Marked-content properties on BeginTaggedContent (v2.119.36)

procedure BeginTaggedContent(const Tag: AnsiString;

  const Lang, Alt, ActualText, Expansion: AnsiString); overload;

 

Description

Table 333 standard structure type enum (v2.119.41): instead of passing free-form strings (which require role-map entries to map non-standard names back to standard types), callers can pass a THPDFStandardStructureType enum value to the typed AddStructureElement overload. The enum covers every standard structure type from PDF 1.7 §14.8.4 Table 333: Document / Part / Art / Sect / Div / BlockQuote / Caption / TOC / TOCI / Index / heading levels H through H6 / list types L / LI / Lbl / LBody / table types Table / TR / TH / TD / THead / TBody / TFoot / inline types Span / Quote / Note / Reference / BibEntry / Code / Link / Annot / Ruby / Warichu / illustration types Figure / Formula / Form.

 

Structure-element attribute setters (v2.119.40): SetStructureElementLang writes /Lang (en-US) per ISO 14289-1 §7.2 for language-specific pronunciation, SetStructureElementExpansion writes /E (Hello World!) to expand abbreviations and acronyms for screen readers, and SetStructureElementTitle writes /T (Section title) to give a tooltip-style human-readable name to a structure element. All three are spec-required for PDF/UA-1 conformance on appropriate element kinds.

 

Marked-content properties on BeginTaggedContent (v2.119.36): the new overload accepts Lang / Alt / ActualText / Expansion properties on the marked-content sequence dict per PDF 1.7 §14.8.4. Alt is the alternate description for non-text content (images, formulas), ActualText is the spoken / extracted-text equivalent (used to override the rendered glyphs for screen readers), Lang overrides the inherited language for the bracketed content, and Expansion spells out abbreviations.

 

Typical workflow (PDF/UA-1 tagged report)

 

PDF.PDFUACompliance := pdfuaPDFUA1;

PDF.BeginDoc;

Doc   := PDF.AddStructureElement(sstDocument, nil);

PDF.SetStructureElementLang(Doc, 'en-US');

H1    := PDF.AddStructureElement(sstH1, Doc);

PDF.SetStructureElementTitle(H1, 'Chapter 1');

Fig   := PDF.AddStructureElement(sstFigure, Doc);

PDF.CurrentPage.BeginTaggedContent('Figure', 'en-US',

  'Annual sales chart, Q1 4.2M, Q2 5.1M, Q3 5.8M, Q4 6.4M', // /Alt

  '', '');

PDF.CurrentPage.ShowImage(ChartImage, ...);

PDF.CurrentPage.EndTaggedContent;

 

PDF/UA compliance gates

When PDFUACompliance is set to pdfuaPDFUA1 the structure-tree surface is mandatory: content streams without a parent structure element raise diagnostic exceptions, missing language declarations raise, and Figure / Formula / Form elements without /Alt or /ActualText raise. Use the typed overload + the attribute setters to satisfy ISO 14289-1 §7.1 - §7.9.

 

See also: THPDFPage.BeginTaggedContent, THotPDF.AddXFAPacket, THotPDF.RegisterAcroFormFont