Rasterex APINPM Package/docs/components/files/api

API References

NPM document-opening methods and their SDK broker mapping.

Public NPM Opening API

Verified against SDK 2.2.3. Mount the viewer and await viewer.ready() before opening a document. Use viewer.documents.open({ url, displayName }) for a Canvas-reachable URL, or viewer.documents.open({ path, displayName }) for a deployment-resolved server path.

Use viewer.documents.openFile(file) for a browser File selected by an input or drop handler. The SDK reads the file and manages request correlation. A matching fileReady event confirms completion; metadata snapshots alone do not resolve opening.

In the example, file is the browser File selected by the operator and viewer is an already mounted, ready SDK viewer.

try {
  const result = await viewer.documents.openFile(file);
  console.log(result.fileReady);
} catch (error) {
  console.error("Document opening failed:", error);
}
Public NPM Opening API

Advanced SDK Broker Mapping

openFile() sends viewFile with the payload below. requestId is generated by the SDK by default; buffer is the ArrayBuffer read from file and included in the transfer list. These names describe SDK internals, not host setup requirements or public exported payload types.

Normal NPM applications call openFile(file); they do not build this payload or manage correlation manually. This mapping does not change the standalone PostMessage contract.

{
  requestId,
  fileName: file.name,
  mime: file.type,
  lastModified: file.lastModified,
  buffer
}
Advanced SDK Broker Mapping