添加 FPdfFormMerge 后即可使用 MergePdfFilesWithForms 或 TPdfFormMergeHelper.MergeFilesWithForms
辅助函数先暂存所选页面导入和字段嫁接,移除导入后失去字段关联的 widget,并独立重新打开已保存结果,再替换调用方文档;错误和取消都会保留目标
pagcpReject 拒绝重复的字段全限定名,pagcpRename 添加确定性的无冲突前后缀,pagcpNamespace 则插入真实的父字段以隔离各源文档
pagcpMergeCompatible 合并兼容的终端文本或选项字段,使其 widget 共享一个值;要求标志、值、默认值、选项和自包含字体语义一致,并拒绝字段动作、富文本和不兼容的字段类型
所选页面过滤会裁掉未使用的 widget 和字段,保留过滤并去重后的计算顺序;默认资源彼此隔离,默认外观名称会重写,而克隆的外观流保留各自资源
兼容字段合并前会规范化字段/widget 合并对象;名称独立的字段在保存并重新打开后仍可独立编辑
InsertAt 是从零开始的插入索引,-1 表示追加页面;Default 上限为总计 10,000 页和每文档 256 MiB,嫁接预算为 100,000 个对象及深度 128
嫁接硬上限为 1,000,000 个对象、深度 256 和 4,096 个根字段;拒绝重复选择页面、XFA 源或目标、已签名源或目标,以及加密目标
源密码可用于解密源文档后执行暂存合并;结果不加密,如需加密,应在之后明确执行加密工作流
旧 GraftPdfAcroForm 重载仍使用拒绝策略;接受 TPdfAcroFormGraftOptions 的重载在流层面提供相同的冲突和资源策略
该表单辅助函数不保留源书签或命名目标;需要导航处理时,使用导航辅助函数所声明的工作流
Options := TPdfFormMergeOptions.Default; Options.GraftOptions.CollisionPolicy := pagcpNamespace; if not MergePdfFilesWithForms(Pdf, Sources, Options, Report) then raise EPdfError.Create(Report.ErrorMessage);
type
TPdfFormMergeOptions= record
GraftOptions: TPdfAcroFormGraftOptions;
InsertAt: Integer;
MaxPages: Integer;
MaxDocumentBytes: Int64;
CancellationToken: IPdfCancellationToken;
class function Default: TPdfFormMergeOptions; static;
end;
TPdfFormMergeReport= record
Succeeded, Cancelled: Boolean;
ImportedSourceCount, ImportedPageCount: Integer;
GraftedFieldCount, RenamedFieldCount, MergedFieldCount: Integer;
FilteredFieldCount, FilteredWidgetCount, ResourceRenameCount: Integer;
ErrorMessage: string;
end;
function MergePdfFilesWithForms(Destination: TPdf;
const Sources: TPdfBatchMergeSources; const Options: TPdfFormMergeOptions;
out Report: TPdfFormMergeReport): Boolean;
type
TPdfFormMergeHelper= class helper for TPdf
function MergeFilesWithForms(const Sources: TPdfBatchMergeSources;
const Options: TPdfFormMergeOptions;
out Report: TPdfFormMergeReport): Boolean;
end;