Rasterex APINPM Package/docs/solutions/compare-drawing-revisions

Compare Drawing Revisions in a Web Application

NPM SDK workflow for comparing or aligning two drawing revisions with confirmed results, errors, and cleanup.

NPM SDK scope and prerequisites

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.

NPM implementation order

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) and viewer.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 inputs

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 dpi when supplied.
  • Require valid colors when color options are supplied.
  • Require a non-empty outputName when supplied.
  • Pass no more than two alignment point objects when using alignArray.

Result, error, and persistence behavior

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.