Migrating to V7 of WebViewer
There are a few breaking changes and other changes when migrating to v7 from older versions.
Breaking changes
New default UI
There is a new default user interface in WebViewer 7.0 which has changed the location and structure of some components in the UI. Most APIs will function the same as before.
One of the main changes is to the header toolbars which are split into several groups. You can change the group using setToolbarGroup and you can edit each group using the getHeader function.
WebViewer(...)
.then(instance => {
// adds a button to the shapes header
instance.setHeaderItems(header => {
const shapesHeader = header.getHeader('toolbarGroup-Shapes');
shapesHeader.push({
type: 'actionButton',
img: '...',
onClick: () => {
// perform action
}
});
});
});If you want to hide a specific toolbar group, like other DOM elements, they can be hidden by using disableElements.
If you are not ready to update to the new UI yet you can still access the previous UI by passing ui: 'legacy' into your WebViewer constructor.
Page numbers instead of page indexes for APIs
Several breaking changes have been made to make sure API signatures are more consistent in WebViewer 7.0. We've heard feedback that it can be confusing using some WebViewer APIs because some accept page indexes (starting with zero) and some accept page numbers (starting with one). In 7.0 we've updated all APIs to be page numbers (starting with one) to be consistent.
Generally if you were using APIs on AnnotationManager and DocumentViewer these were already taking in 1-indexed page numbers. If you were using APIs on the Document object these were taking in 0-indexed page numbers.
Below are some examples of the changes:
The following APIs have been changed to use page numbers:
DocumentViewer textSelected
TextTool textSelected
The following DOM elements have been changed to use page numbers:
#pageContainer#pageWidgetContainer
PartRetrievers cannot be accessed directly
Previously you could reference a PartRetriever directly from the PartRetriever namespace. Now the PartRetrievers are lazy loaded when needed so you can access them through the asynchronous getPartRetriever API.
ResultCode has been moved to the CoreControls namespace
The XODText namespace has been removed from the iframe window, and ResultCode belongs to the CoreControls namespace now.
Deprecated usages
In WebViewer 7.0, we also renamed some constant variables to be more consistent with others. Their previous names are kept for backwards compatibility, though we still encourage you to update them.
APIs removed
A few very rarely used APIs have been removed related to CanvasManager canvas modes.
CoreControls.CanvasMode CoreControls.setCanvasMode DocumentViewer.setPagesPerCanvas DocumentViewer.returnCanvas
Other
The fileAttachmentDataAvailable event is now fired on AnnotationManager instead of DocumentViewer.
Last updated
Was this helpful?