Compare Drawing Revisions in a Web Application
NPM SDK workflow for comparing or aligning two drawing revisions with confirmed results, errors, and cleanup.
This solution uses the NPM SDK. Mount the viewer, await viewer.ready(), and keep a viewer reference available for cleanup. The host must provide two distinct Canvas-reachable sources or supported file-name inputs.
Use the NPM revision workflow, Compare API, and Align API for the exact method and event contracts.
The NPM host should advance from the documented promise result or event, not from the button click.
- 1Create, mount, and ready the viewer.
- 2Register
viewer.compare.on("comparisonComplete", handleComplete)andviewer.compare.on("comparisonError", handleError)before the action. - 3Validate distinct sources and optional compare settings.
- 4Call
viewer.compare.compare({ backgroundUrl, overlayUrl })for compatible coordinates. - 5Call
viewer.compare.align({ backgroundUrl, overlayUrl })when the operator must select matching points. - 6Treat an empty comparison-complete result during interactive align as the point-selection state.
- 7Show the output only after the payload-bearing completion and documented promise resolution.
- 8Unsubscribe and call
viewer.destroy()on route cleanup.
Validate host inputs before calling the SDK. The component reference defines the SDK constraints.
- Provide one background source and one overlay source.
- Reject identical background and overlay values.
- Require a positive finite
dpiwhen supplied. - Require valid colors when color options are supplied.
- Require a non-empty
outputNamewhen supplied. - Pass no more than two alignment point objects when using
alignArray.
viewer.compare.compare(...) returns a Promise<ComparisonResult>. Use its outputFileUrl and result metadata only after the promise resolves. The documented comparison event channels provide progress, completion, and error state for the host UI.
Comparison output is separate from markup persistence. The deprecated viewer.compare.save(...) behavior is not part of a new integration workflow; use the documented annotation save or host persistence flow when the user must retain markups.
On error or timeout, preserve valid source inputs, unlock retry, clear stale result state, and keep the route cleanup idempotent.
React setup
Copy the NPM React revision workspace.
Prepare revisions
Validate sources and choose compare or align.
Compare revisions
Implement direct comparison and result handling.
Verification checklist
Verify success, failure, cancellation, and cleanup.
Continue with the complete NPM workflow pages.
