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.
Because comparison calls resolve asynchronously via event handlers, subscribe to the compare event channels before executing a compare action:
compare(...)returnsvoid. All progress updates, success payloads, and errors are delivered via the event handlers.
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:
Save the collaborative comparison markup or set output file naming properties:
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.save(...)maps tocompareSave.viewer.compare.on("progressStart", ...)listens toprogressStart.viewer.compare.on("progressEnd", ...)listens toprogressEnd.viewer.compare.on("comparisonComplete", ...)listens tocomparisonComplete.viewer.compare.on("comparisonError", ...)listens tocomparisonError.viewer.compare.on("compareSaveComplete", ...)listens tocompareSaveComplete.
