SetEmbeddedFileAFRelationship
PDF/UA & Accessibility
Description
Sets the AFRelationship key on the file specification dictionary for an embedded file. Required by ISO 14289-1 (PDF/UA-1) §7.11 when embedded files are included in an accessible PDF document.
Syntax
Delphi
function TPDFlib.SetEmbeddedFileAFRelationship(Index: Integer; const AFRelationship: WideString): Integer;ActiveX
Function PDFlib::SetEmbeddedFileAFRelationship(Index As Long, AFRelationship As String) As LongDLL
int DLSetEmbeddedFileAFRelationship(int InstanceID, int Index, wchar_t * AFRelationship);Parameters
| Index | Zero-based index of the embedded file. Valid range: 0 to EmbeddedFileCount - 1. |
|---|---|
| AFRelationship | The relationship of the embedded file to the document. Must be one of the following case-sensitive values: Source — the embedded file is the source file used to create the document Data — the embedded file contains data used by the document Alternative — the embedded file is an alternative representation of the document content Supplement — the embedded file is supplemental to the document Unspecified — the relationship is not specified (default when SetPDFUAMode is active) |
Return value
Returns 1 on success. Returns 0 if the index is out of range, the AFRelationship value is not one of the five valid values, or no document is open.
Remarks
When SetPDFUAMode is active, PDFlibPas automatically sets AFRelationship to Unspecified for any embedded file that does not already have the key. Use SetEmbeddedFileAFRelationship before saving to override this default with a more specific relationship value.
Call this function after adding the embedded file and before saving the document.
Example
// PDF/A-3 archive that embeds an XLSX as the document's source data
var
FileID: Integer;
begin
PDF.SetPDFAMode(5); // PDF/A-3b — allows arbitrary embedded files
PDF.NewDocument;
PDF.AddStandardFont('Helvetica');
PDF.AddPage;
PDF.PrintText(50, 750, 'Quarterly Sales Report');
FileID := PDF.AddEmbeddedFile(
'sales-Q1.xlsx',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
PDF.AddFileAttachment('Source spreadsheet', FileID);
// Mark the relationship: the spreadsheet is the source of the report
PDF.SetEmbeddedFileAFRelationship(0, 'Source');
PDF.SaveToFile('report-PDFA3b.pdf');
end;See also
SetPDFUAMode, SetPDFAMode, AddFileAttachment, AddEmbeddedFile, EmbedFile, SetEmbeddedFileStrProperty