File Upload
Load documents into the canvas and manage session states through the documents surface.
File Upload allows you to load documents into the canvas by providing a valid file URL/path.
Use the documents surface when the file is reachable by Canvas through a URL or server path:
- `viewer.documents.open(options)`: The file is reachable by Canvas through a URL or server path (sends the
viewAnybroker command).
Select the appropriate configuration parameters depending on your storage and integration environment:
Pass the public URL of the document you want Canvas to load:
- The URL must be accessible by Canvas. If Canvas is hosted on a separate domain, ensure your file server has cross-origin headers (CORS) enabled.
Use path when your Canvas deployment resolves paths relative to its own server root or environment:
Furnish metadata properties to configure tabs and cache settings:
- `displayName`: The display label Canvas shows inside file tabs. It must include the file extension (e.g.
Plan.pdf, not justPlan). - `cacheId`: A stable cache key. Canvas servers check for previously generated viewable assets under this key to bypass reprocessing on subsequent loads.
- `mime`: Explicitly states the document MIME type, helping Canvas select the proper file handler.
Capture the asynchronous loading phase and session metadata using event subscriptions:
Register listeners before starting loading operations, and save the unsubscribe handles:
Subscribe to canvas broadcast streams to render custom host side elements:
Safely catch document exceptions and adjust default load timeout values:
Import RasterexViewerError to extract detailed canvas codes:
- `VIEWER_NOT_READY`: Rejects if
.open()is invoked beforeawait ready()resolves. - `DOCUMENT_LOAD_FAILED`: Rejects if
url/pathare missing, another document loading task is in progress, or the canvas fails to return metadata before timing out.
If you expect large drawings that require extensive server-side parsing, adjust the commandTimeoutMs on the viewer instance:
Import SDK typing interfaces for full type-safety inside your editor:
- `DocumentOpenOptions`: Defines URL, server path, display name, cache key, and mime configurations.
- `DocumentOpenResult`: Defines the resolved promise output containing correlation IDs and file details.
The SDK converts methods to internal broker frames as shown below:
- `viewer.documents.open(...)` maps to the Canvas command `viewAny`.
- `viewer.documents.on("fileInfo", ...)` subscribes to the Canvas event `fileInfo`.
- `viewer.documents.on("fileTabs", ...)` subscribes to the Canvas event `fileTabs`.
- `viewer.documents.on("pageList", ...)` subscribes to the Canvas event `pageList`.
Copy these project setup files to configure mounting, event subscriptions, and file loading handles:
Open URLs inside a standard React functional hook:
Open URLs inside a Vue composition component setup:
Open URLs inside an Angular component:
Test the interactive preview below to see how the session initializes when a new file is requested.
Interactive Workbench
File upload preview
Paste a file URL and send the view message to load a new file in the Canvas.
Continue with related file workflows and API references.
- Canvas Setup: Canvas Iframe Initialization
- File Management: File Management
- File API: API References
