Migrating to V11 of WebViewer

There are a few breaking changes and other deprecated APIs when migrating to v11 from older versions.

Modular UI

WebViewer is now using the new Modular UI by default. The Modular UI is very flexible and allows for more customization as well as the ability to import and export UI configs. More details can be found in the Migrating to Modular UI guide.

The previous UI is still available and can be used by setting the ui option to legacy in the WebViewer constructor.

JavaScript

1WebViewerConstructor(
2 {
3 path: '/path/to/your/webviewer',
4 initialDoc: '/path/to/your/document.pdf',
5 ui: 'legacy',
6 },
7 document.getElementById('viewer')
8).then(instance => {
9
10});

Web Component

Starting in version 11 WebViewer will be instantiated in a Web Component by default instead of an iframe. This change will affect how you interact with the WebViewer DOM and apply CSS styles.

While Web Component is now the default way to instantiate WebViewer, you can still use an iframe by replacing the WebViewer function with WebViewer.Iframe and it will work as it did before.

JavaScript

1import WebViewer from '@pdftron/webviewer'
2
3WebViewer.Iframe({
4 path: '/public/webviewer',
5 licenseKey: 'YOUR_LICENSE_KEY',
6}, document.getElementById('viewer'))
7 .then(instance => {
8
9 })

For more information on these changes, please refer to the following guide: Running WebViewer as a Web Component.

Form Builder

There are a few breaking changes to the Form Builder experience when migrating to v11 from older versions. More details can be found in the Migrating to v11 Form Builder guide.

APIs removed

Previously deprecated APIs that have been removed:

FormFieldCreationManager

  • FormFieldCreationManager.setFieldFlag has been removed, please use WidgetAnnotation.setFieldFlag
  • FormFieldCreationManager.setFieldValue has been removed, please use WidgetAnnotation.setFieldValue
  • FormFieldCreationManager.setFieldOptions has been removed, please use WidgetAnnotation.setFieldOptions
  • FormFieldCreationManager.getFieldFlag has been removed, please use WidgetAnnotation.getFieldFlag
  • FormFieldCreationManager.getFieldName has been removed, please use WidgetAnnotation.getFieldName
  • FormFieldCreationManager.getFieldValue has been removed, please use Field.getValue
  • FormFieldCreationManager.getFieldOptions has been removed, please use WidgetAnnotation.getFieldOptions
  • FormFieldCreationManager.getWidgetFromPlaceholder has been removed, placeholders are no longer utilized.
  • FormFieldCreationManager.applyFormFields has been removed, fields no longer need to be applied.
  • FormFieldCreationManager.getWidgetFromPlaceholder has been removed, placeholders are no longer utilized.

Annotations

  • Core.Annotations.Annotation.isFormFieldPlaceholder has been removed, placeholders are no longer utilized.
  • Core.Annotations.Annotation.getFormFieldPlaceholderType has been removed, placeholders are no longer utilized.
  • Core.Annotations.Annotation.getFormFieldPlaceHolderType has been removed, placeholders are no longer utilized.
  • The ImageData property on Core.Annotations.StampAnnotation has been removed. Please use the getImageData and setImageData functions instead.
  • The annot property on Core.Annotations.SignatureWidgetAnnotation has been removed. Please use the getAssociatedSignatureAnnotation and setAssociatedSignatureAnnotation functions instead.

Webviewer UI

Document

setStyles parameter change

The Core.Tools.Tool function setStyles previously accepted either an object or a function as a parameter. It now only accepts an object with the properties to be set; it no longer accepts a function.

MultiViewerMode / SideBySideView

SignatureCreateTool

By default the SignatureCreateTool will now sign all widgets using appearances. Signing with an annotation will still be supported. For more information on these two methods of signing and how to switch between them, please refer to the following guide: Signing with Appearances.

Signature fields signed with an e-signature appearance may not be visible in Adobe with form field highlighting turned on.

  • The annot property has been removed. Please use getFullSignatureAnnotation or getInitialsAnnotation instead to get the annotation associated with the full signature and initials respectively.
  • The ctx property has been removed. Please use the signatureDrawingCanvases property instead.

AnnotationManager.addAnnotation autoFocus option

Previously, if the autoFocus option for the addAnnotation API was not specified, the annotation would automatically focus for editing after being added. In version 11, the autoFocus option will default to false. To retain the previous behavior, developers will now need to explicitly set autoFocus: true when calling addAnnotation.

sh

1annotationManager.addAnnotation(myFreeText); // autoFocus is now false by default
2annotationManager.addAnnotation(myFreeText, { autoFocus: true }); // enables autoFocus

Core

  • Core.SetCachingLevel has been removed. Please use Core.setCachingLevel instead.
  • Core.SetPreRenderLevel has been removed. Please use Core.setPreRenderLevel instead.

UI

On the instance.UI namespace the following functions were removed:

  • disableAnnotations, disableDownload, disableFilePicker, disableLocalStorage, disableMeasurement, disableNotesPanel, disablePrint, disableRedaction, disableTextSelection, disableTouchScrollLock (as well as the enable versions)
    • Instead use instance.UI.disableFeatures or instance.UI.enableFeatures with the corresponding instance.UI.Feature constant.
  • getAnnotationUser, instead use Core.annotationManager.getCurrentUser
  • getCurrentPageNumber, instead use Core.documentViewer.getCurrentPage
  • getPageCount, instead use Core.documentViewer.getPageCount
  • getShowSideWindow and getSideWindowVisibility, instead use UI.isElementOpen('leftPanel')
  • goToFirstPage, instead use Core.documentViewer.setCurrentPage(1)
  • goToLastPage, instead use Core.documentViewer.setCurrentPage(Core.documentViewer.getPageCount())
  • goToNextPage, instead use Core.documentViewer.setCurrentPage(Core.documentViewer.getCurrentPage() + 1)
  • goToPrevPage, instead use Core.documentViewer.setCurrentPage(Core.documentViewer.getCurrentPage() - 1)

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales