PDFium Delphi Component Docs

交易式 AcroForm 合併

加入 FPdfFormMerge,即可使用 MergePdfFilesWithForms 或 TPdfFormMergeHelper.MergeFilesWithForms

輔助功能先暫存選定頁面匯入與欄位嫁接,移除匯入後成為孤立的 Widget,再獨立重新開啟儲存結果,確認後才取代呼叫端文件;錯誤與取消操作均保留目的端

pagcpReject 拒絕重複的完整欄位名稱,pagcpRename 加入可重現且無衝突的前綴與後綴,pagcpNamespace 則插入真正的父欄位以隔離每個來源

pagcpMergeCompatible 合併相容的終端文字或選項欄位,使其 Widget 共用同一值;旗標、值、預設值、選項及自足的字型語意必須一致,欄位動作、RTF 文字及不相容欄位類型會遭拒絕

頁面篩選會裁去未使用的 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;