PDFium Delphi Component 文件

AttachmentRelationship 属性

组件: TPdf  ·  单元: PDFium
返回指定零基索引处嵌入文件的 /AFRelationship 名称;文件规范没有该条目时返回空字符串

语法

property AttachmentRelationship[Index: Integer]: WString; // read only

说明

PDF 2.0 的关联文件(ISO 32000-2 §7.11.4)会给每个文件规范打上一个 /AFRelationship 名称,说明嵌入文件与其附着内容之间的关系:Source、Data、Alternative、Supplement、EncryptedPayload、FormData、Schema 或 Unspecified(Table 43)。PDF/A-3 以及 ZUGFeRD / Factur-X 电子发票就依靠该条目来标记机器可读的 XML 载荷

该属性通过原生 FPDFAttachment_GetAFRelationship 导出读取条目,并以 Unicode 字符串返回原始的名称标记。文件规范没有 /AFRelationship 条目、条目不是名称,或者已加载的 pdfium.dll 早于该导出时(见 AttachmentRelationshipFeaturesAvailable),返回空字符串

该属性是只读的。要带关系地附加文件,请使用 FPdfAssocFiles 中的 Pascal 侧写入器,它输出同样的名称标记

参数

IndexInteger。基于 0 的附件槽位。必须满足 0 <= Index < AttachmentCount;其他取值会抛出 EPdfError(Incorrect attachment index)

备注

示例

var
  I: Integer;
begin
  Pdf1.LoadFromFile('invoice-facturx.pdf');
  for I := 0 to Pdf1.AttachmentCount - 1 do
    if Pdf1.AttachmentRelationship[I] = 'Alternative' then
      SaveInvoiceXml(Pdf1.AttachmentName[I], Pdf1.Attachment[I]);
end;

参见

AttachmentName, AttachmentType, AttachmentDescription, ReadAttachmentMetadata, AttachmentRelationshipFeaturesAvailable