Some test text!

Loading...
Guides

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.

<!-- Version 3.x and older -->
<script src='lib/WebViewer.min.js'></script>

<!-- Version 4.0 and after -->
<script src='lib/webviewer.min.js'></script>

No more jQuery

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

<!-- Version 3.x and older -->
<script src='lib/html5/external/jquery-3.2.1.min.js'></script>

<!-- Version 4.0 and after -->
<!-- nothing! -->

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

// Version 3.x and older
$(viewerElement).on('documentLoaded', function() {
  ...
});

// Version 4.0 and after
viewerElement.addEventListener('documentLoaded', function() {
  ...
});

// Version 3.x and older
$(viewerElement).on('pageChanged', function(e, pageNumber) {
  console.log(pageNumber);
});

// Version 4.0 and after
viewerElement.addEventListener('pageChanged', function(e) {
  const [ pageNumber ] = e.detail;
  console.log(pageNumber);
});

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:

// Version 3.x and older
annotManager.drawAnnotations(1);
// something that relies on the annotations to be finished drawing

// Version 4.0 and after
annotManager.drawAnnotations(1).then(function() {
  // something that relies on the annotations to be finished drawing
});

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.

Get the answers you need: Support