Quick Start
Add the Rasterex viewer to a web application, open a document, enable measurement tools, and receive annotation events through the @rasterex/viewer SDK.
Install the Rasterex viewer SDK using your package manager of choice.
This is the smallest complete, runnable application to mount the viewer and open a document. Copy these four files into your workspace to get started immediately:
Verify your minimal integration works correctly:
- A full-page viewer canvas loads automatically inside your browser window.
- The sample PDF document (
sample.pdf) is rendered in the center of the canvas area. - You can scroll, zoom, drag, and navigate the document pages out-of-the-box.
Initialize the minimal document setup in your choice of frontend framework using these optimized integration structures:
Mount the viewer inside a lifecycle useEffect hook and bind it to a DOM container reference. Copy the component code:
Create the viewer instance inside the onMounted lifecycle hook, and call destroy() inside onBeforeUnmount. Copy the Vue script:
Initialize the viewer within ngAfterViewInit using standalone module settings and clean templates. Copy the Angular component files:
Once you verify the minimal layout displays drawings, build custom user interactions by subscribing to creation events and control commands:
Listening for Annotation Events: Add an event listener to run code when annotations are drawn: viewer.annotations.on("created", (event) => { console.log(event.guid); }).
Activating Drawing Tools: Control drawing tools programmatically: viewer.tools.set({ group: "annotation", action: "TEXT", enabled: true }).
Resetting Selection State: Clear active tool highlight overlays back to standard navigation mode: viewer.tools.clear().
The SDK routes commands to the Canvas broker interface through the following steps:
- `mount()`: Dynamic HTML iframe generation and DOM injection to set up event bridge channels.
- `ready()`: Internal state handshakes wait for Canvas client readiness before accepting document actions.
- `documents.open({ url, displayName })`: File retrieval broker dispatch that loads documents directly in the iframe.
Watch out for these frequent mistakes when setting up your NPM integration:
- 0px Container Height: If your CSS container lacks an explicit height ruleset, the iframe renders with a height of 0px and is invisible.
- Pre-Ready Commands: Calling
.open()or.tools.set()beforeawait ready()resolves will throw error exceptions. - Component Memory Leaks: In single-page applications, always save event handles and invoke them alongside
viewer.destroy()during component destruction.
Explore detailed APIs to customize integration scopes:
- Learn advanced settings in Viewer Setup (or
?s=npm). - Manage documents using Canvas Session.
- Analyze annotation methods inside Annotation API.
