Rasterex APINPM Package/docs/solutions/compare-pdf-dwg-versions

Compare PDF and DWG Versions in a Web Application

NPM SDK solution for comparing PDF or DWG source revisions with verified promise, event, alignment, and cleanup behavior.

NPM SDK scope

Use the NPM SDK after creating, mounting, and readying the viewer. Pass two distinct source URLs or supported file-name inputs to the compare or align method. Confirm file-format and deployment support with the Canvas environment used by your application.

Read the NPM Compare API, NPM Align API, and NPM Revision Workflow for the complete contracts.

NPM implementation flow

Keep source selection and confirmed comparison state separate in the host.

  • 1Await viewer.mount() and viewer.ready() before using compare APIs.
  • 2Subscribe to viewer.compare.on("comparisonComplete", handleComplete) and viewer.compare.on("comparisonError", handleError) before starting.
  • 3Validate distinct PDF or DWG source values and optional rendering settings.
  • 4Call viewer.compare.compare({ backgroundUrl, overlayUrl }) when coordinates are compatible.
  • 5Call viewer.compare.align({ backgroundUrl, overlayUrl }) when the operator must select matching points.
  • 6Treat an empty completion result during interactive alignment as an intermediate point-selection state.
  • 7Await the comparison promise and show outputFileUrl only after the result confirms completion.
  • 8Unsubscribe and destroy the viewer during route cleanup.

Validate inputs and outputs

Apply the documented compare constraints before the call.

  • Require a background source and an overlay source.
  • Reject identical source values.
  • Require a positive finite dpi when supplied.
  • Validate optional output colors and non-empty outputName.
  • Pass no more than two alignment point objects when using alignArray.
  • Treat the returned ComparisonResult as comparison output; annotation persistence is a separate workflow.

Recovery and cleanup

During processing, disable duplicate compare and align actions while keeping the selected sources visible. During interactive alignment, keep cancellation and the point-selection instruction available.

On rejection or comparisonError, preserve correctable inputs, clear stale result metadata, and enable retry. Do not claim that the source format is supported based only on a successful input validation; the Canvas deployment must accept and process the file.

Comparison output does not save markups or host records. Use the documented annotation and persistence APIs for those operations.

Continue with the NPM workflow

Use the workflow pages for the complete React implementation and acceptance checks.