CompareRenderedPagesWith

Document comparison, Rendering

Requires the Small Business edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibSmallBusiness (unit PDFlibSmallBusiness) or TPDFlibEnterprise; this method is Pascal-only: it takes a second library instance, which the C and Automation ABIs do not carry, so no DLL, ActiveX or Dylib build exports it; the Single edition keeps the method, which returns False and sets LastErrorCode to 901 (PDFLIB_ERROR_SMALLBUSINESS_REQUIRED)

Description

Compare two rendered pages and obtain difference artifacts

Syntax

Function TPDFlib.CompareRenderedPagesWith(Other: TPDFlib;
  ThisPage, OtherPage: Integer; DPI: Double;
  Const Options: TPDFVisualCompareOptions;
  Out Comparison: TPDFVisualCompareResult; Out ErrorText: WideString): Boolean; Virtual;

Parameters

OtherThe second library instance; its document must be loaded and it renders with its own renderer, crop, scale, colour, annotation and form settings
ThisPageOne-based page number in this document; validated without clamping and the previous selection is restored
OtherPageOne-based page number in Other; validated and restored the same way
DPIFinite positive rendering resolution in dots per inch, applied to both pages
OptionsTPDFVisualCompareOptions with ColorTolerance from 0 through 255 inclusive per channel, TileSize for grouping adjacent changed tiles, IgnoreRects of top-left half-open pixel rectangles, and the IncludeMask and IncludeOverlay requests; start from PLDefaultVisualCompareOptions
ComparisonReceives the bitmap size, the compared, changed and ignored pixel counts, the changed ratio, the changed bounding box, changed regions and the requested mask and overlay; reset to an empty result when the call fails
ErrorTextReceives the failure reason when the result is False, and an empty string on success

Return values

TrueBoth pages were rendered and compared, whether or not they differ; Comparison holds the measurements and any requested artifacts
FalseInvalid input, a render failure or unequal bitmap dimensions; Comparison is empty, ErrorText describes the failure and LastErrorCode is 401

Remarks

Returns True when rendering and comparison complete, including when the pages differ; returns False with ErrorText and an empty result on invalid input, render failure, or unequal dimensions

Page numbers are one-based and are validated without clamping; both selected pages are restored after rendering

Use PLDefaultVisualCompareOptions from PDFlibVisualCompare; ColorTolerance is an inclusive per-channel threshold from 0 to 255, TileSize groups adjacent changed tiles, and IgnoreRects contains top-left half-open pixel rectangles

Set IncludeMask for one byte per pixel (255 changed, 0 unchanged or ignored) and IncludeOverlay for an RGB copy of the second page with changed pixels tinted red; the changed ratio excludes ignored pixels

The result contains actual changed bounds and counts; empty changed bounds serialize as null; at most 64M pixels and 4M tiles are accepted

The inputs use their configured renderer, crop, scale, color, annotation, and form settings; configure both instances consistently when comparing document content

See also

CompareDocumentVisualsWith, CompareFileVisuals