Rasterex APINPM Package/docs/components/revision/api

API References

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

Compare Method

Call viewer.compare.compare(...) when both source files are already positioned correctly and you want the canvas to generate a visual diff.

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)"
});
Compare Method

Align Method

Call viewer.compare.align(...) when the source files require interactive point matching or headless alignment before comparison.

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.

  • 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, error.reason);
});
Result Events