SetStructElemAltTextA
標籤式 PDF 與無障礙
Description
結尾的 A 表示 ANSI(char)DLL 進入點,ActiveX/COM 介面僅公開 Unicode 形式。其行為與 SetStructElemAltText 相同,字串引數會依據目前的 SetAnsiMode 字碼頁進行解譯
Sets the /Alt entry on the structure element currently being built on the tag stack. Alternative text is the text description that assistive technology (screen readers, braille displays) presents to users when the element cannot be rendered visually — for example, an image, figure, or mathematical formula.
此函式等同對 BeginTag 或 BeginTagEx 傳入非空 AltText 參數,但允許在元素開啟之後才設定或更新替代文字。元素類型確定之後,描述才非同步算出或取得時,這就很實用。
語法
Delphi
Function DLSetStructElemAltTextA(InstanceID: Integer; AltText: PAnsiChar): Integer;
DLL
int DLSetStructElemAltTextA(int InstanceID, const char * AltText);
參數
| AltText | 要與目前結構元素關聯的替代文字描述。傳入空字串可清除先前設定。 |
|---|
Return value
成功傳回 1;目前沒有開啟中的結構元素或未選取文件時傳回 0
Remarks
在 BeginTag 之後、目標元素位於標籤堆疊頂端時立即呼叫此函式,或在對應的 EndTag 呼叫之前的任何時點呼叫。
AltText and ActualText serve different purposes. AltText is a complete textual substitute for the entire element — it replaces the visual content for users who cannot perceive the rendered output. ActualText (ISO 32000-1 §14.9.4) provides the exact Unicode character sequence for inline glyphs whose extracted text would otherwise be incorrect (such as ligatures), and does not replace rendering. Screen readers typically speak AltText for Figure and Formula elements, and use ActualText for character-level corrections.
ISO 32000-1 §14.9.3 defines the /Alt entry. PDF/UA-1 (ISO 14289-1 §7.5) requires alternative descriptions on Figure and Formula structure elements. GetPDFUADiagnostics reports the FIGURE-NO-ALT:N issue code when Figure or Formula elements are missing Alt text.
範例
// Tag an embedded chart image with alternative text
PDFlib.BeginTag('Figure', '', '');
PDFlib.SetStructElemAltText('Bar chart: Q1 sales 120, Q2 sales 145, Q3 sales 98');
PDFlib.SetStructElemBBox(x, y, x + w, y + h);
PDFlib.DrawImage(imgHandle, x, y, w, h);
PDFlib.EndTag;另見
BeginTag, BeginTagEx, SetStructElemActualText, SetStructElemLang, GetPDFUADiagnostics