ComparePreflightReports
Compliance, Document inspection
Description
Compares two plain-text preflight reports and returns a compact line-by-line diff when their stable content differs. Use this API to detect report drift in regression tests, CI jobs, or delivery checks that keep a baseline report next to a PDF fixture.
Syntax
Delphi
function TPDFlib.ComparePreflightReports(const ReportA, ReportB: WideString): WideString;
Parameters
| ReportA | Baseline plain-text report, usually produced by CreatePreflightReport or read back from a file created by SavePreflightReport. |
|---|---|
| ReportB | Current plain-text report to compare with the baseline. |
Return value
Returns an empty string when the reports match after normalising volatile Generated: timestamp lines. When stable content differs, the result starts with PDFlibPas Preflight Report Diff; shared lines use a two-space prefix, lines only in ReportA use - , and lines only in ReportB use + .
Remarks
The comparison is designed for the deterministic text output produced by CreatePreflightReport. It does not parse JSON, HTML, or CSV reports; compare the plain-text form when a workflow needs stable regression gates and then generate any formatted report needed for humans or downstream tools. See Preflight Reports for the full command-line and batch workflow.
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
Preflight Reports, CreatePreflightReport, CreatePreflightReportEx, SavePreflightReport, SavePreflightReportEx, CheckFileCompliance