AddTagAttribute
标记 PDF、可访问性
描述
向当前在标记栈中构建的结构元素添加具名属性。保存文档时,该属性会写为 PDF /A 属性字典(或字典数组)。请在 BeginTag 或 BeginTagEx 之后、EndTag 之前调用此方法
语法
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, const wchar_t * Owner, const wchar_t * Name, const wchar_t * Value);
参数
| Owner | ISO 32000-1 表 348 定义的属性所有者名称(例如 Layout、Table、List、PrintField)。它会成为属性字典中的 /O 键 |
|---|---|
| Name | 给定所有者的属性名称(例如 Layout 的 BBox、Table 的 Scope)不得为空 |
| Value | 作为字符串的属性值。单个数字会写为 PDF 数字,仅包含以空格分隔数字的值(例如 "0 0 200 100")会写为 PDF 实数数组。数字在任何系统上都用点作小数点,用系统自身小数点符号写出的数字也被接受。其他任何值会写为 PDF 名称对象(不带前导 /)。不得为空 |
返回值
成功时返回 1。未打开文档、当前未打开标签,或 Owner 或 Name 为空时返回 0
备注
对同一开放标记多次调用 AddTagAttribute 会累积属性 当属性属于单一所有者时,库会写入一个 /A 属性字典 使用多个所有者时,属性会按所有者分组,并写入为属性字典数组
对于常见属性,可使用便捷包装器 SetStructElemScope 和 SetStructElemBBox,而非直接调用 AddTagAttribute
打开新标签时会重置属性;子元素不会继承这些属性
示例
// 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;另请参阅
BeginTag, BeginTagEx, EndTag, SetStructElemScope, SetStructElemBBox