property AttachmentRelationship[Index: Integer]: WString; // read only
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
| Index | Integer. Zero-based attachment slot. Must satisfy 0 <= Index < AttachmentCount; any other value raises an EPdfError (Incorrect attachment index) |
/EmbeddedFiles name tree carry an index; an associated file referenced solely from an /AF array cannot be reached through this property (see AttachmentCount)Relationship field of TPdfAttachmentMetadata, and TryGetAnnotationFileAttachment fills the matching field for file-attachment annotations
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;