AddPDFA3AssociatedFileFromString

Document properties

Description

Creates an embedded file stream from memory bytes, adds the file specification to the document attachment name tree, and registers it in the Catalog /AF array for PDF/A-3 workflows

Syntax

Delphi

Function TPDFlib.AddPDFA3AssociatedFileFromString(Const FileName, MIMEType, Description, Relationship: WideString; Const FileBytes: AnsiString): Integer;

Parameters

FileNameThe displayed file name for the attachment, such as invoice.xml
MIMETypeThe MIME type written to the embedded file stream, such as text/xml or application/xml
DescriptionThe optional /Desc text written to the file specification
RelationshipThe /AFRelationship value, usually Source, Data, Alternative, Supplement, or Unspecified
FileBytesThe raw bytes to store in the embedded file stream

Return values

0No active document, invalid parameters, or the current document is not in a PDF/A-3 mode
Non-zeroThe object handle of the newly created file specification

Remarks

The file is visible in the document attachment list and is also referenced by the Catalog /AF array required by PDF/A-3 associated files

For standard Factur-X, ZUGFeRD, or XRechnung invoice XML, prefer AddFacturXAssociatedFileFromString so the invoice metadata and profile checks are written consistently

Example

// Attach source XML to a PDF/A-3b document
var
  FileID: Integer;
begin
  PDF.SetPDFAMode(5);
  PDF.NewDocument;
  FileID := PDF.AddPDFA3AssociatedFileFromString(
    'invoice.xml',
    'text/xml',
    'Invoice source data',
    'Source',
    InvoiceXML);
  if FileID = 0 then Exit;
  PDF.SaveToFile('archive.pdf');
end;

See also

AddFacturXAssociatedFileFromString, SetPDFAMode, SetEmbeddedFileAFRelationship, AddEmbeddedFile