ComparePreflightReports

Compliance, Document inspection

Description

比較兩份純文字預檢報告,並在它們的穩定內容不同時傳回精簡的逐行差異;使用此 API 可在迴歸測試、CI 工作或傳遞檢查中偵測報告偏移,並在 PDF 測試固件旁保留基準報告

Syntax

Delphi

Function TPDFlib.ComparePreflightReports(Const ReportA, ReportB: WideString): WideString;

Parameters

ReportA基準純文字報告,通常由 CreatePreflightReport 產生,或從 SavePreflightReport 建立的文件中讀回
ReportB用於與基準進行比較的目前純文字報告

Return value

在將易變的 Generated: 時間戳記行正規化後,如果報告相符,則傳回空字串;當穩定內容不同時,結果會以 PDFlibPas Preflight Report Diff 開頭;共用行使用兩個空格的字首,僅在 ReportA 中的行使用 - ,而僅在 ReportB 中的行使用 +

Remarks

此比較是針對 CreatePreflightReport 產生的確定性文字輸出所設計,它不會剖析 JSON、HTML 或 CSV 報告;當工作流程需要穩定的迴歸關卡時,請比較純文字形式,然後產生人類或下游工具所需的任何格式化報告,請參閱 Preflight Reports 取得完整的命令列和批次工作流程

Example

Baseline := TFile.ReadAllText('expected-preflight.txt', TEncoding.UTF8);
Current := PDF.CreatePreflightReport('output.pdf', '', 1 or 2, 0);
Diff := PDF.ComparePreflightReports(Baseline, Current);
if Diff <> '' then
  TFile.WriteAllText('preflight.diff.txt', Diff, TEncoding.UTF8);

See also

預檢報告, CreatePreflightReport, CreatePreflightReportEx, SavePreflightReport, SavePreflightReportEx, CheckFileCompliance