PDFium Delphi Component Docs

AttachmentRelationship property

Component: TPdf  ·  Unit: PDFium
Gives the /AFRelationship name of the embedded file at the given zero-based index, or an empty string when the file specification carries none

Syntax

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

Description

PDF 2.0 associated files (ISO 32000-2 §7.11.4) tag each file specification with an /AFRelationship name describing how the embedded file relates to the content it accompanies: Source, Data, Alternative, Supplement, EncryptedPayload, FormData, Schema or Unspecified (Table 43). PDF/A-3 and ZUGFeRD / Factur-X invoices depend on this entry to mark the machine-readable XML payload

The property fetches the entry through the native FPDFAttachment_GetAFRelationship export and hands back the raw name token as a Unicode string. An empty string is returned when the file specification carries no /AFRelationship entry, when the entry is not a name, or when the loaded pdfium.dll predates the export (see AttachmentRelationshipFeaturesAvailable)

The property is read-only. To attach files with a relationship, use the Pascal-side writer in FPdfAssocFiles, which emits the same name tokens

Parameters

IndexInteger. Zero-based attachment slot. Must satisfy 0 <= Index < AttachmentCount; any other value raises an 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