Integrate the online viewer in a web page
Follow these instructions to display a document in the web browser.
- Create an iframe element with a <src> value that points to where the online viewer is hosted:{domain}/mobile/v.
- Attach an event listner to the window, waiting for amessage event.The firstmessageevent the web app receives contains theVIEWER:READYID, which means that the online viewer has finished loading and is now waiting for the containing web app to send all the relevant values via aPARENT:INITpostMessage.
- For files in a workspace, define the message with the following values:
- accessToken: string
- simpleShare: boolean
- documentGuid: string
- For files in an external repository, define the message with the following values:
- accessToken: string
- simpleShare: boolean
- transient: boolean
- documentPath: string
- workspaceGuid: string
The document will be displayed once the online viewer receives the message. - Optional: Define that the parent page send a new access token to the online viewer ifram using thePARENT:SET_ACCESS_TOKENmessage:{ "id": "PARENT:SET_ACCESS_TOKEN", "context": { "accessToken": "new_access_token" } }
- Optional: Define that the online viewer iframe inform the parent about various actions and state changes in the online viewer:
- VIEWER:INVALID_ACCESS_TOKEN
- VIEWER:DOCUMENT_NOT_FOUND
- VIEWER:NO_PERMISSION_FOR_RECIPIENT
- VIEWER:REQUEST_EXTENSION (context: { expired: boolean })
- VIEWER:PRINT_PERMISSION_REQUEST (context: { name: string })
- VIEWER:CONVERSSION_TIMEOUT
- VIEWER:CONVERSION_FAILED
- VIEWER:MAX_SIZE_EXCEEDED
- VIEWER:UNEXPECTED_ERROR