There are a few breaking changes and other deprecated APIs when migrating to v8 from older versions.
This is not actually a breaking change since you can still access the old namespaces, but a number of namespaces have been restructured to more logically group things. All of the WebViewer Core namespaces can now be found on instance.Core and all of the UI related APIs and namespaces can be found on instance.UI. The CoreControls namespace now only exists for backwards compatibility and you can access all functions that were previously found on CoreControls, directly on the Core namespace.
annotManager has been renamed to annotationManager
docViewer has been renamed to documentViewer
on has been renamed to addEventListener
off has been renamed to removeEventListener
Before:
After:
When running code inside a config file you can now access instance on the window and it will be identical to the instance that is resolved from the WebViewer function. readerControl no longer exists inside the WebViewer iframe.
"Custom data" is stored on annotations and is automatically saved and restored when exporting and importing XFDF, as well as downloading and re-opening a PDF. Custom data is compatible across all platforms using Apryse APIs, so for example with the Android Apryse SDK you could retrieve custom data that was stored by WebViewer.
To be consistent and fully compatible with other platforms the setCustomData function now only accepts a string as the value. If you pass something other than a string it will automatically be stringified. Similarly getCustomData will only return a string.
To more easily enforce the proper types, setting of the CustomData property directly is now no longer possible. Please use setCustomData to set your properties instead.
If you would like to use object types you can use JSON.stringify and JSON.parse, or parseInt and parseFloat for numbers.
Before:
After:
With WebViewer 8.0 the legacy UI is not officially supported. If you would like to continue using the legacy UI you can stay on version 7.3. Note that the legacy 7.3 branch is available in the public UI repo and you can attempt to update it to be compatible with 8.0 if you like.
The associateLink, getAssociatedLinks and unassociateLinks APIs have been removed. Links are now associated with annotations by using the normal annotation grouping APIs, for example annotationManager.groupAnnotations.
If you have associated links already saved in your XFDF then WebViewer will automatically convert them over to groups the next time they are loaded.
Before:
After:
In previous version when all annotations were deselected the annotationSelected event would provide null as the annotations parameter of the event for a deselect action. Now all deselect actions will return an array of the annotations that were deselected, never null.
Before:
After:
The file lib/core/CoreControls.js has been renamed to lib/core/webviewer-core.min.js.
The AnnotationManager function getDisplayAuthor previously would take an annotation object as a parameter and returned the transformed author name, however sometimes there were times that a transformed author name was needed but no annotation object existed yet.
In WebViewer 8.0 the getDisplayAuthor function now accepts the author id so that it can be used in all cases, with or without an anotation. This also means that the setAnnotationDisplayAuthorMap callback function receives an author id instead of an annotation.
Before:
After:
With support for form field creation directly in the UI the WidgetEditingManager class has been replaced by the FormFieldCreationManager which includes all the functionality of the old WidgetEditingManager along with new field creation support. Previously you would use annotManager.getWidgetEditingManager() and now annotationManager.getFormFieldCreationManager().
RubberStampCreateTool
SignatureCreateTool
The NoZoom property on annotations now works consistently for all types of annotations. If you were overriding the draw function for sticky note annotations then it has changed somewhat. Previously the canvas context was already translated to where the sticky note was drawn, but now you must first translate by annotation.X and annotation.Y.
Before:
After:
The callback for documentViewer.setPagesUpdatedInternalAnnotationsTransform now provides 1-indexed page numbers instead of 0-indexed page numbers.
Before:
After:
The documentViewer.select function expects the point objects to have the pageNumber property instead of pageIndex.
Before:
After:
To make the API more consistent many boolean APIs have mostly moved to the form enableXYZ/disableXYZ/isXYZEnabled. The previous functions are still accessible but have been deprecated.
AnnotationManager
setReadOnly becomes enableReadOnlyMode, disableReadOnlyMode, isReadOnlyModeEnabledsetFreeformRotationEnabled becomes enableFreeformRotation, disableFreeformRotationenableRedaction(boolean) becomes enableRedaction, disableRedactionsetIsAdminUser, getIsAdminUser becomes promoteUserToAdmin, demoteUserFromAdmin, isUserAdminDocumentViewer
getRightToLeftPages, setRightToLeftPages becomes enableRightToLeftPageRendering, disableRightToLeftPageRendering, isRightToLeftPageRenderingEnabledsetLoadAnnotationsFromVisiblePages becomes enableLoadingAnnotationsFromVisiblePages, disableLoadingAnnotationsFromVisiblePagessetEnableAutomaticLinking becomes enableAutomaticLinking, disableAutomaticLinkingsetEnableStylusMode becomes enableStylusMode, disableStylusModeDocument
enableColorSeparations(boolean) becomes enableColorSeparations, disableColorSeparationssetOfflineModeEnabled becomes enableOfflineMode, disableOfflineModeTools
AnnotationSelectTool.setEnableImmediateActionOnAnnotationSelection becomes AnnotationSelectTool.enableImmediateActionOnAnnotationSelection, AnnotationSelectTool.disableImmediateActionOnAnnotationSelectionDistanceMeasurementCreateTool.setEnableLeaderLines becomes DistanceMeasurementCreateTool.enableLeaderLines, DistanceMeasurementCreateTool.disableLeaderLinesRedactionCreateTool.setEnableTextAutoSize becomes RedactionCreateTool.enableAutoSizedText, RedactionCreateTool.disableAutoSizedTextsetAllowCreationOverAnnotation becomes enableCreationOverAnnotation, disableCreationOverAnnotationOther
CoreControls.enableFullPDF(boolean) becomes Core.enableFullPDF, Core.disableFullPDFannotation.setRotationControlEnabled becomes annotation.enableRotationControl, annotation.disableRotationControlpopupAnnotation.setOpen becomes popupAnnotation.open, popupAnnotation.closepdftronServer becomes webviewerServerURLPreviously deprecated APIs that have been removed:
new PDFTron.WebViewer constructor for WebViewer has been removed.Before:
After:
annotation.getLeft() use annotation.getX() or annotation.X insteadannotation.getRight() use annotation.X + annotation.Width insteadannotation.getTop() use annotation.getY() or annotation.Y insteadannotation.getBottom() use annotation.Y + annotation.Height insteadsignatureWidget.isSignedInitially() use signatureWidget.isSignedDigitally() insteadannotationManager.getAnnotCommand() use annotationManager.exportAnnotCommand() insteadDid you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales