PDFium Delphi Component 文件

AttachmentRelationship 屬性

元件: TPdf  ·  單元: PDFium
傳回指定以 0 起算索引處內嵌檔案的 /AFRelationship 名稱;檔案規格未攜帶該項目時則傳回空字串

Syntax

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

Description

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 端寫入器,它會發出相同的名稱代碼

Parameters

IndexInteger。以 0 起算的附件槽位。必須滿足 0 <= Index < AttachmentCount;其他值會引發 EPdfError(Incorrect attachment index)

Remarks

Example

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;

See Also

AttachmentName, AttachmentType, AttachmentDescription, ReadAttachmentMetadata, AttachmentRelationshipFeaturesAvailable