SetEmbeddedFileAFRelationshipA
PDF/UA & 可访问性
描述
末尾的 A 表示 ANSI(char)DLL 入口点,ActiveX/COM 接口仅公开 Unicode 形式。其行为与 SetEmbeddedFileAFRelationship 相同,字符串参数会按照当前的 SetAnsiMode 代码页进行解释
在嵌入文件的文件规范字典中设置 AFRelationship 键,ISO 14289-1 (PDF/UA-1) §7.11 要求可访问 PDF 文档包含嵌入文件时设置该键
语法
Delphi
Function DLSetEmbeddedFileAFRelationshipA(InstanceID, Index: Integer; AFRelationship: PAnsiChar): Integer;
DLL
int DLSetEmbeddedFileAFRelationshipA(int InstanceID, int Index, const char * AFRelationship);
参数
| Index | 嵌入文件的从 1 开始的索引。有效范围:1 到 EmbeddedFileCount |
|---|---|
| AFRelationship | 嵌入文件与文档的关系。必须为以下区分大小写的值之一: Source — 嵌入文件是用于创建文档的源文件 Data — 嵌入文件包含文档使用的数据 Alternative — 嵌入文件是文档内容的替代表示 Supplement — 嵌入文件是文档的补充 Unspecified — 未指定关系(启用 SetPDFUAMode 时的默认值) |
返回值
成功时返回 1。如果索引超出范围、AFRelationship 值不是五个有效值之一,或未打开文档,则返回 0
备注
当 SetPDFUAMode 处于活动状态时,PDF Library for Delphi 会自动将尚未具有该键的任何嵌入文件的 AFRelationship 设置为 Unspecified,保存前使用 SetEmbeddedFileAFRelationship 可用更具体的关系值覆盖此默认设置
添加嵌入文件后且保存文档前调用此函数
示例
// 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(1, 'Source');
PDF.SaveToFile('report-PDFA3b.pdf');
end;另请参阅
SetPDFUAMode、SetPDFAMode、AddFileAttachment、AddEmbeddedFile、EmbedFile、SetEmbeddedFileStrProperty