Compare
Create visual file comparisons from two source files using the SDK compare interface.
Use viewer.compare.compare(...) to create a visual comparison from two file sources.
Compare commands are available after the viewer is mounted and Canvas is ready. viewer.compare.save(...) is deprecated and is not part of this new-integration workflow.
Because comparison calls report completion asynchronously, subscribe to the terminal compare event channels before executing a compare action:
compare(...)starts the operation. Use local UI state for pending/loading, then clear it fromcomparisonCompleteorcomparisonError.
Execute visual diff generation by passing background and overlay URLs:
- Canvas loads the background and overlay files, builds the comparison overlay, opens the generated file, and emits
comparisonComplete.
If files reside in the Canvas file base directory, you can query using file names directly:
Supported compare configuration payloads and shapes:
The SDK performs validation before triggering the Canvas comparing commands:
- Background source (
backgroundUrlorbackgroundFileName) is required. - Overlay source (
overlayUrloroverlayFileName) is required. - Background and overlay values must be different.
dpimust be a positive finite number if provided.backgroundColor,overlayColor, andequalColormust be valid hex orrgb(...)colors.outputNamemust be a non-empty string if provided.
Complete integration code setup for Vanilla HTML/JS environments:
Broker message mapping for compare workflows:
viewer.compare.compare(...)maps tocompare.viewer.compare.on("comparisonComplete", ...)listens tocomparisonComplete.viewer.compare.on("comparisonError", ...)listens tocomparisonError.viewer.compare.on("progressStart", ...)andviewer.compare.on("progressEnd", ...)report Canvas activity.
