Rasterex APINPM Package/docs/components/revision/api

API References

Technical reference for compare, align, and revision result events.

Compare Method

Call viewer.compare.compare({ backgroundUrl, overlayUrl }) when both source files are already positioned correctly and you want Canvas to generate a visual diff. Verified against SDK 2.2.3, it returns Promise<ComparisonResult> and resolves after the payload-bearing comparisonComplete and following progressEnd events.

The promise rejects on invalid input, unavailable readiness, a conflicting pending comparison operation, Canvas comparison errors, command timeout, or disconnect. Handle rejection to restore host controls and show a recoverable error. Example URLs below must be replaced with Canvas-reachable source URLs.

try {
  const result = await viewer.compare.compare({
    backgroundUrl: "https://files.example.com/bg.pdf",
    overlayUrl: "https://files.example.com/overlay.pdf",
    dpi: 200,
    backgroundColor: "#E86767",
    overlayColor: "#0E3BD8",
    equalColor: "rgb(128,128,128)"
  });

  console.log("Comparison output:", result.outputFileUrl);
} catch (error) {
  console.error("Comparison failed:", error);
}
Compare Method

Align Method

Call viewer.compare.align({ backgroundUrl, overlayUrl, alignArray }) when the source files require interactive point matching, or when the host already has alignArray point objects.

viewer.compare.align({
  backgroundUrl: "https://files.example.com/bg.pdf",
  overlayUrl: "https://files.example.com/overlay.pdf",
  dpi: 200,
  backgroundColor: "#E86767",
  overlayColor: "#0E3BD8"
});
Align Method

Result Events

Both compare and align report through the same completion and error event listeners on viewer.compare. Compare additionally returns a promise; align remains event-driven.

  • comparisonComplete: Fires when the compare or align workflow finishes successfully (or reaches the interactive align stage).
  • comparisonError: Fires when the compare or align workflow fails.
viewer.compare.on("comparisonComplete", (result) => {
  if (result) {
    console.log("Completed with file:", result.relativePath);
  } else {
    console.log("Ready for interactive alignment.");
  }
});

viewer.compare.on("comparisonError", (error) => {
  console.error("Comparison error:", error.message);
});
Result Events