Migrating to v4

There are a few breaking changes when migrating to v4 from older versions.

Case change

UpperCamelCase in the main files, WebViewer.min.js and WebViewer.js, have been updated to lowercase.

HTML

1<!-- Version 3.x and older -->
2<script src='lib/WebViewer.min.js'></script>
3
4<!-- Version 4.0 and after -->
5<script src='lib/webviewer.min.js'></script>

No more jQuery

From 4.0, you don't need to load jquery before WebViewer anymore.

HTML

1<!-- Version 3.x and older -->
2<script src='lib/html5/external/jquery-3.2.1.min.js'></script>
3
4<!-- Version 4.0 and after -->
5<!-- nothing! -->

This means that event-listening functions need to be updated too.

JavaScript

1// Version 3.x and older
2$(viewerElement).on('documentLoaded', function() {
3 ...
4});
5
6// Version 4.0 and after
7viewerElement.addEventListener('documentLoaded', function() {
8 ...
9});
10
11// Version 3.x and older
12$(viewerElement).on('pageChanged', function(e, pageNumber) {
13 console.log(pageNumber);
14});
15
16// Version 4.0 and after
17viewerElement.addEventListener('pageChanged', function(e) {
18 const [ pageNumber ] = e.detail;
19 console.log(pageNumber);
20});

AnnotationManager drawAnnotations is asynchronous

The drawAnnotations function is now asynchronous and returns a promise that resolves when drawing has completed.

Generally this won't cause problems for existing code as long as subsequent code isn't relying on the annotation drawing to have completed. If you do rely on this then you'll just need to move the code into a then block. For example:

JavaScript

1// Version 3.x and older
2annotManager.drawAnnotations(1);
3// something that relies on the annotations to be finished drawing
4
5// Version 4.0 and after
6annotManager.drawAnnotations(1).then(function() {
7 // something that relies on the annotations to be finished drawing
8});

New default viewer

The default viewer has been updated to WebViewer UI v1, which means that customizations you've made to the UI for the legacy viewer will not work anymore. Note that the new default viewer does not support IE9 or 10. If you want to support IE9 and 10 you will need to use the legacy viewer.

Also note that customizations using the WebViewer core APIs remain mostly unchanged so those customizations will continue to work.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales