SaveVisualComparisonPDF

Small Business, visual comparison

Requires the Small Business edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibSmallBusiness (unit PDFlibSmallBusiness) or TPDFlibEnterprise; the Small Business and Enterprise DLL and ActiveX builds provide it unchanged; the Single edition keeps the method, which returns an empty string and sets LastErrorCode to 901 (PDFLIB_ERROR_SMALLBUSINESS_REQUIRED)

Description

Compares the selected document against a baseline and saves a separate review PDF containing both sides of each page pair, with red difference frames on current pages and blue frames on baseline pages

Syntax

Delphi

Function TPDFlib.SaveVisualComparisonPDF(Const BaselineFileName, BaselinePassword,
  OptionsJSON, OutputFileName: WideString): WideString; Virtual;

ActiveX

Function PDFlib::SaveVisualComparisonPDF(BaselineFileName As String, BaselinePassword As String, OptionsJSON As String, OutputFileName As String) As String

DLL

const wchar_t* DLSaveVisualComparisonPDF(int InstanceID, const wchar_t* BaselineFileName, const wchar_t* BaselinePassword, const wchar_t* OptionsJSON, const wchar_t* OutputFileName);
const char* DLSaveVisualComparisonPDFA(int InstanceID, const char* BaselineFileName, const char* BaselinePassword, const char* OptionsJSON, const char* OutputFileName);

Parameters

BaselineFileNamePath of the baseline PDF whose pages are compared against the selected document
BaselinePasswordPassword for the baseline file, or an empty string when it is not encrypted
OptionsJSONOptional JSON object; an empty string uses dpi 96, colorTolerance 0 and tileSize 32. dpi accepts 72 through 300, colorTolerance 0 through 255, tileSize 4 through 128, and maxRasterPixels and maxOutputBytes each accept 1 through 536870912
OutputFileNameNew local .pdf path for the review document; an existing file is never replaced

Return values

Returns JSON with status, complete, the structured comparison, the source-to-output pages map, runtimeBackend, rectangleCount, output name, byte count and SHA-256. Successful output has status:"ok" and complete:true; errors use status:"error" with error 906, cancellation returns status:"cancelled" with error 907, and the Single edition returns an empty string with error 901.

Options

An empty options string uses the defaults below; unknown properties, noninteger values and out-of-range values fail before output is written

{"dpi":96,"colorTolerance":0,"tileSize":32}
OptionRangeMeaning
dpi72 to 300Resolution used to compare rendered page appearances
colorTolerance0 to 255Per-channel pixel difference tolerance
tileSize4 to 128Pixel tile size used to group changed regions

Progress, cancellation and budgets

Typed OnOperationProgress and classic OnProgress events are forwarded to the calling instance; Abort is observed at safe points and during supported native rendering, with one terminal workflow phase

Options additionally accept maxRasterPixels, default 134217728, and maxOutputBytes, default 536870912; both are integers from 1 through 536870912

Pixel work is estimated from both sets of source-page geometry before rendering and checked against actual rendered dimensions; output writes are bounded before exceeding the byte limit

Cancellation returns status:"cancelled", complete:false and error 907 without publishing a partial review PDF; call ResetAbort before starting another workflow on a cancelled instance

Return values

Returns JSON with status, complete, the original structured comparison, a source-to-output pages map, the actual runtimeBackend ID, rectangleCount, output file name, byte count and SHA-256

Successful output has status:"ok" and complete:true; errors return status:"error", complete:false and error 906, without publishing a partial review PDF

Single instances return an empty string with error 901; Small Business and Enterprise implement the operation; ActiveX exposes it through IPDFlibrary9 or CoPDFlibrary.CreateEditionTools9; Dylib exposes the same wide and ANSI names with cdecl

Page geometry and limits

The comparison uses each page's CropBox at the requested DPI; copied pages retain vector content, page boxes, rotation and UserUnit, and pixel regions are mapped back into source-page coordinates

Page additions and removals are defined from baseline to current, with direction:"baseline-to-current" in the comparison; missing partners and size changes receive whole-visible-page frames; page labels identify the source side, source page and pair; unchanged paired pages remain available for review

Each input supports 1 to 256 pages and a 256 MiB serialized source limit; difference regions are bounded to 4096 per page, and the output is limited to 512 MiB

The selected document, font and drawing settings, modification metadata and rendering settings are retained; output requires a new local .pdf path and never replaces an existing file; a compatible selected rendering backend must be available

This is a raster appearance review at one resolution, with fullCertification:false; it does not establish semantic equivalence, preserve signature validity in the review copy, or certify standards conformance

Example

Report:= PDF.SaveVisualComparisonPDF('baseline.pdf', '',
  '{"dpi":144,"colorTolerance":0,"tileSize":32}', 'visual-review.pdf');

Run the shared workflow CLI example through the Delphi, Lazarus or C++Builder entry for the required edition, including progress and batch cancellation

TRIAL delivery retains the evaluation watermark on temporary output objects; batch conversion applies it before format conversion so raster output contains the mark inside its image data, while internal source snapshots remain unchanged

See also

CompareDocumentVisualsWith · SaveTextComparisonPDF · GetFeatureAvailability · Edition comparison