File Upload
Load documents into the canvas and manage session states through a communication bridge.
File Upload allows you to load documents into the canvas by providing a valid file URL or by passing a real browser File object from an input element. This process initializes the canvas tools and establishes the metadata state for the session.
By managing files through the communication bridge, you maintain total control over document access while leveraging the high-performance rendering engine.
- URL Loading: The file URL must be publicly accessible on the internet.
- Any File URL Loading: The viewAny message accepts fileUrl, displayName, cacheId, and mime.
- Display Name: Use the complete file name with extension, such as Sample.pdf or Apple Sample.pdf.
- Local Loading: The viewFile message requires a real browser File object, usually from an input[type="file"].
- Dynamic Loading: Open any supported document format on the fly.
- Session Lifecycle: Track the status of document processing from start to finish.
- Automated Initialization: Canvas tools auto-calibrate based on the loaded file type.
Send a view payload to load a file and listen for fileInfo to confirm readiness.
Load a file
Load a local browser File
Load a file URL with metadata
Listen for fileInfo
Loading a document follows a request-response pattern. You dispatch a view, viewAny, or viewFile message to start the rendering process, and the canvas provides status updates until the document is ready.
1. Host Requests File with Metadata
Use viewAny when the host needs to provide fileUrl, displayName, cacheId, and mime. displayName must include the file extension, for example Sample.pdf or Apple Sample.pdf.
1a. Host Requests File URL
Send view with a file URL to initialize the session.
1b. Host Requests Local File
Use viewFile when the document comes from the user computer. The payload must contain the actual File object.
2. Canvas Returns Metadata
The canvas broadcasts the fileInfo event once the document is fully loaded and ready for interaction.
The canvas emits specific events to help you manage UI loaders and progress indicators during document processing.
- progressStart: Emitted when the canvas begins downloading or parsing a file.
- progressEnd: Emitted when the processing is complete and the UI is interactive.
Initialize the iframe, load a file from either a URL or a local file input, and handle progress and metadata events.
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
