For the complete documentation index, see llms.txt. This page is also available as Markdown.

Migrating to V6 of WebViewer

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

No more jQuery

CoreControls.js is no longer dependent on jQuery, thus all APIs that use jQuery are changed.

Event handling

The jQuery e isn't passed to event handlers as the first argument anymore. The imported property for annotationChanged is now accessible on the third argument.

// Version 5.x and older
docViewer.on('zoomUpdated', (e, zoom) => {
  ...
});
annotManager.on('annotationChanged', (e, annotations, action) => {
  if (e.imported) {
    ...
  }
});

// Version 6.0 and after
docViewer.on('zoomUpdated', zoom => {
  ...
});
annotManager.on('annotationChanged', (annotations, action, info) => {
  if (info.imported) {
    ...
  }
});

Event trigger for annotationChanged

Since the event handler now takes an info object as a third argument, it should be also included when manually triggering an annotationChanged event.

CreateInnerElement

The innerElement of all widget annotations is now a normal DOM element instead of a jQuery wrapped element. This means that createInnerElement should return a normal DOM element now.

SetSignatureCanvas

It takes a canvas element instead of a jQuery wrapped canvas element.

Config file

jQuery is no longer accessible inside a config file. The viewerLoaded and documentLoaded events are triggered on the window instead of the wrapped document object now.

AnnotationManager getAnnotCommand is asynchronous

Previously this API didn't wait for the resources to be loaded for annotations before exporting them, which may result in an empty ImageData property for stamp annotations. Now this API waits for it internally. This API is deprecated in favor of exportAnnotCommand.

AnnotationManager exportAnnotations is asynchronous

Previously this API didn't wait for the freehand tool to finish drawing before exporting the XFDF, which may result in missing freehand annotations data. It didn't wait for the resources to be loaded as described above. Now the API waits for it internally.

AnnotationManager importAnnotCommand is asynchronous

AnnotationManager importAnnotations is asynchronous

AnnotationManager importAnnotationsAsync is replaced with importAnnotations

The Annotations.Annotation Custom property

The Custom property is mainly used to store a custom property to an annotation. Prior to 6.0 you need to extend Annotations.Annotation's serialize and deserialize methods to make sure that this property shows in the exported XFDF. In 6.0 we replace this property with CustomData. The value of it will be serialized to the output XFDF, and even better, be preserved in the downloaded document.

GetCustomData

Inside a config file, this function is moved to the readerControl object.

Document Viewer getCompleteRotation API requires a parameter

docViewer.getCompleteRotation now requires a page number as the first parameter.

Last updated

Was this helpful?