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.
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.
Keep source selection and confirmed comparison state separate in the host.
- 1Await
viewer.mount()andviewer.ready()before using compare APIs. - 2Subscribe to
viewer.compare.on("comparisonComplete", handleComplete)andviewer.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
outputFileUrlonly after the result confirms completion. - 8Unsubscribe and destroy the viewer during route cleanup.
Apply the documented compare constraints before the call.
- Require a background source and an overlay source.
- Reject identical source values.
- Require a positive finite
dpiwhen supplied. - Validate optional output colors and non-empty
outputName. - Pass no more than two alignment point objects when using
alignArray. - Treat the returned
ComparisonResultas comparison output; annotation persistence is a separate workflow.
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.
React revision setup
Implement the NPM React comparison workspace.
Prepare revisions
Validate sources and choose compare or align.
Compare revisions
Handle comparison progress, result, and retry.
Verification checklist
Verify lifecycle, result confirmation, and cleanup.
Use the workflow pages for the complete React implementation and acceptance checks.
