@pdftools/four-heights-pdf-web-viewer 4.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +446 -0
- package/README.md +145 -0
- package/css/pdf-web-viewer.css +2407 -0
- package/doc/PdfWebViewer.pdf +0 -0
- package/es6/common/Checkbox.d.ts +9 -0
- package/es6/common/Checkbox.js +8 -0
- package/es6/common/Color.d.ts +23 -0
- package/es6/common/Color.js +118 -0
- package/es6/common/ColorPicker.d.ts +15 -0
- package/es6/common/ColorPicker.js +46 -0
- package/es6/common/Contextbar.d.ts +6 -0
- package/es6/common/Contextbar.js +19 -0
- package/es6/common/DragMoveHandler.d.ts +51 -0
- package/es6/common/DragMoveHandler.js +175 -0
- package/es6/common/Dropdown.d.ts +36 -0
- package/es6/common/Dropdown.js +76 -0
- package/es6/common/DropdownMenu.d.ts +9 -0
- package/es6/common/DropdownMenu.js +10 -0
- package/es6/common/DropdownSeparator.d.ts +3 -0
- package/es6/common/DropdownSeparator.js +6 -0
- package/es6/common/Icon.d.ts +13 -0
- package/es6/common/Icon.js +8 -0
- package/es6/common/Loader.d.ts +3 -0
- package/es6/common/Loader.js +6 -0
- package/es6/common/RangeSlider.d.ts +17 -0
- package/es6/common/RangeSlider.js +42 -0
- package/es6/common/StrokeStylePicker.d.ts +11 -0
- package/es6/common/StrokeStylePicker.js +20 -0
- package/es6/common/StrokeWidthPicker.d.ts +11 -0
- package/es6/common/StrokeWidthPicker.js +20 -0
- package/es6/common/Toolbar.d.ts +10 -0
- package/es6/common/Toolbar.js +6 -0
- package/es6/common/ToolbarButton.d.ts +14 -0
- package/es6/common/ToolbarButton.js +21 -0
- package/es6/common/ToolbarFileButton.d.ts +15 -0
- package/es6/common/ToolbarFileButton.js +27 -0
- package/es6/common/ToolbarItemGroup.d.ts +8 -0
- package/es6/common/ToolbarItemGroup.js +12 -0
- package/es6/common/ToolbarSeparator.d.ts +3 -0
- package/es6/common/ToolbarSeparator.js +6 -0
- package/es6/common/Tools.d.ts +10 -0
- package/es6/common/Tools.js +89 -0
- package/es6/common/TooltipManager.d.ts +12 -0
- package/es6/common/TooltipManager.js +54 -0
- package/es6/common/TranslationManager.d.ts +11 -0
- package/es6/common/TranslationManager.js +61 -0
- package/es6/common/classNames.d.ts +2 -0
- package/es6/common/classNames.js +18 -0
- package/es6/common/formatDate.d.ts +1 -0
- package/es6/common/formatDate.js +1 -0
- package/es6/common/icons.d.ts +13 -0
- package/es6/common/icons.js +412 -0
- package/es6/common/utils.d.ts +2 -0
- package/es6/common/utils.js +19 -0
- package/es6/custom/history.d.ts +2 -0
- package/es6/custom/history.js +59 -0
- package/es6/index.d.ts +5 -0
- package/es6/index.js +5 -0
- package/es6/lib/hyperapp/index.d.ts +108 -0
- package/es6/lib/hyperapp/index.js +327 -0
- package/es6/modules/CanvasLayer.d.ts +32 -0
- package/es6/modules/CanvasLayer.js +83 -0
- package/es6/modules/CanvasModule.d.ts +59 -0
- package/es6/modules/CanvasModule.js +98 -0
- package/es6/modules/eraser/EraserLayer.d.ts +13 -0
- package/es6/modules/eraser/EraserLayer.js +141 -0
- package/es6/modules/eraser/EraserModule.d.ts +19 -0
- package/es6/modules/eraser/EraserModule.js +34 -0
- package/es6/modules/eraser/EraserToolbar.d.ts +10 -0
- package/es6/modules/eraser/EraserToolbar.js +30 -0
- package/es6/modules/form-fields/CheckBoxWidget.d.ts +9 -0
- package/es6/modules/form-fields/CheckBoxWidget.js +45 -0
- package/es6/modules/form-fields/ComboBoxWidget.d.ts +22 -0
- package/es6/modules/form-fields/ComboBoxWidget.js +152 -0
- package/es6/modules/form-fields/EditFormFieldLayer.d.ts +17 -0
- package/es6/modules/form-fields/EditFormFieldLayer.js +238 -0
- package/es6/modules/form-fields/FormFieldModule.d.ts +15 -0
- package/es6/modules/form-fields/FormFieldModule.js +27 -0
- package/es6/modules/form-fields/ListBoxWidget.d.ts +9 -0
- package/es6/modules/form-fields/ListBoxWidget.js +73 -0
- package/es6/modules/form-fields/RadioButtonWidget.d.ts +9 -0
- package/es6/modules/form-fields/RadioButtonWidget.js +45 -0
- package/es6/modules/form-fields/SelectListWidget.d.ts +9 -0
- package/es6/modules/form-fields/SelectListWidget.js +45 -0
- package/es6/modules/form-fields/TextBoxWidget.d.ts +9 -0
- package/es6/modules/form-fields/TextBoxWidget.js +53 -0
- package/es6/modules/form-fields/WidgetBase.d.ts +23 -0
- package/es6/modules/form-fields/WidgetBase.js +29 -0
- package/es6/modules/freetext-annotation/AddFreetextAnnotationLayer.d.ts +19 -0
- package/es6/modules/freetext-annotation/AddFreetextAnnotationLayer.js +181 -0
- package/es6/modules/freetext-annotation/AddFreetextAnnotationToolbar.d.ts +21 -0
- package/es6/modules/freetext-annotation/AddFreetextAnnotationToolbar.js +37 -0
- package/es6/modules/freetext-annotation/EditFreetextAnnotationLayer.d.ts +20 -0
- package/es6/modules/freetext-annotation/EditFreetextAnnotationLayer.js +211 -0
- package/es6/modules/freetext-annotation/EditFreetextAnnotationToolbar.d.ts +50 -0
- package/es6/modules/freetext-annotation/EditFreetextAnnotationToolbar.js +118 -0
- package/es6/modules/freetext-annotation/FreetextAnnotationModule.d.ts +28 -0
- package/es6/modules/freetext-annotation/FreetextAnnotationModule.js +58 -0
- package/es6/modules/freetext-annotation/RichTextEditor.d.ts +31 -0
- package/es6/modules/freetext-annotation/RichTextEditor.js +223 -0
- package/es6/modules/highlight-annotation/AddHighlightAnnotationLayer.d.ts +31 -0
- package/es6/modules/highlight-annotation/AddHighlightAnnotationLayer.js +289 -0
- package/es6/modules/highlight-annotation/AddHighlightAnnotationToolbar.d.ts +20 -0
- package/es6/modules/highlight-annotation/AddHighlightAnnotationToolbar.js +52 -0
- package/es6/modules/highlight-annotation/EditHighlightAnnotationLayer.d.ts +15 -0
- package/es6/modules/highlight-annotation/EditHighlightAnnotationLayer.js +104 -0
- package/es6/modules/highlight-annotation/EditHighlightAnnotationToolbar.d.ts +15 -0
- package/es6/modules/highlight-annotation/EditHighlightAnnotationToolbar.js +28 -0
- package/es6/modules/highlight-annotation/HighlightAnnotationModule.d.ts +27 -0
- package/es6/modules/highlight-annotation/HighlightAnnotationModule.js +54 -0
- package/es6/modules/image-annotations/ImageAnnotationModule.d.ts +23 -0
- package/es6/modules/image-annotations/ImageAnnotationModule.js +169 -0
- package/es6/modules/index.d.ts +13 -0
- package/es6/modules/index.js +13 -0
- package/es6/modules/ink-annotation/AddInkAnnotationLayer.d.ts +40 -0
- package/es6/modules/ink-annotation/AddInkAnnotationLayer.js +503 -0
- package/es6/modules/ink-annotation/AddInkAnnotationToolbar.d.ts +30 -0
- package/es6/modules/ink-annotation/AddInkAnnotationToolbar.js +53 -0
- package/es6/modules/ink-annotation/EditInkAnnotationLayer.d.ts +20 -0
- package/es6/modules/ink-annotation/EditInkAnnotationLayer.js +137 -0
- package/es6/modules/ink-annotation/EditInkAnnotationToolbar.d.ts +25 -0
- package/es6/modules/ink-annotation/EditInkAnnotationToolbar.js +47 -0
- package/es6/modules/ink-annotation/InkAnnotationModule.d.ts +27 -0
- package/es6/modules/ink-annotation/InkAnnotationModule.js +50 -0
- package/es6/modules/popup/Popup.d.ts +64 -0
- package/es6/modules/popup/Popup.js +360 -0
- package/es6/modules/popup/PopupLayer.d.ts +31 -0
- package/es6/modules/popup/PopupLayer.js +509 -0
- package/es6/modules/popup/PopupModule.d.ts +16 -0
- package/es6/modules/popup/PopupModule.js +25 -0
- package/es6/modules/print-service/PrintServiceDialog.d.ts +30 -0
- package/es6/modules/print-service/PrintServiceDialog.js +134 -0
- package/es6/modules/print-service/PrintServiceLayer.d.ts +24 -0
- package/es6/modules/print-service/PrintServiceLayer.js +310 -0
- package/es6/modules/print-service/PrintServiceModule.d.ts +18 -0
- package/es6/modules/print-service/PrintServiceModule.js +30 -0
- package/es6/modules/shape-annotations/AddShapeAnnotationLayer.d.ts +24 -0
- package/es6/modules/shape-annotations/AddShapeAnnotationLayer.js +210 -0
- package/es6/modules/shape-annotations/AddShapeAnnotationToolbar.d.ts +26 -0
- package/es6/modules/shape-annotations/AddShapeAnnotationToolbar.js +69 -0
- package/es6/modules/shape-annotations/EditShapeAnnotationLayer.d.ts +19 -0
- package/es6/modules/shape-annotations/EditShapeAnnotationLayer.js +148 -0
- package/es6/modules/shape-annotations/EditShapeAnnotationToolbar.d.ts +24 -0
- package/es6/modules/shape-annotations/EditShapeAnnotationToolbar.js +57 -0
- package/es6/modules/shape-annotations/ShapeAnnotationModule.d.ts +28 -0
- package/es6/modules/shape-annotations/ShapeAnnotationModule.js +50 -0
- package/es6/modules/stamp-annotation/AddStampAnnotationLayer.d.ts +19 -0
- package/es6/modules/stamp-annotation/AddStampAnnotationLayer.js +257 -0
- package/es6/modules/stamp-annotation/AddStampAnnotationToolbar.d.ts +17 -0
- package/es6/modules/stamp-annotation/AddStampAnnotationToolbar.js +68 -0
- package/es6/modules/stamp-annotation/StampAnnotationModule.d.ts +20 -0
- package/es6/modules/stamp-annotation/StampAnnotationModule.js +35 -0
- package/es6/modules/text-annotation/AddTextAnnotationLayer.d.ts +14 -0
- package/es6/modules/text-annotation/AddTextAnnotationLayer.js +132 -0
- package/es6/modules/text-annotation/AddTextAnnotationToolbar.d.ts +15 -0
- package/es6/modules/text-annotation/AddTextAnnotationToolbar.js +27 -0
- package/es6/modules/text-annotation/TextAnnotationModule.d.ts +19 -0
- package/es6/modules/text-annotation/TextAnnotationModule.js +34 -0
- package/es6/pdf-viewer-api/ImageContainer.d.ts +10 -0
- package/es6/pdf-viewer-api/ImageContainer.js +43 -0
- package/es6/pdf-viewer-api/PdfViewerApi.d.ts +463 -0
- package/es6/pdf-viewer-api/PdfViewerApi.js +732 -0
- package/es6/pdf-viewer-api/PdfViewingWrapper.d.ts +178 -0
- package/es6/pdf-viewer-api/PdfViewingWrapper.js +2037 -0
- package/es6/pdf-viewer-api/annotationDefaultBehaviors.d.ts +3 -0
- package/es6/pdf-viewer-api/annotationDefaultBehaviors.js +30 -0
- package/es6/pdf-viewer-api/enums.d.ts +100 -0
- package/es6/pdf-viewer-api/enums.js +113 -0
- package/es6/pdf-viewer-api/index.d.ts +3 -0
- package/es6/pdf-viewer-api/index.js +3 -0
- package/es6/pdf-viewer-api/types.d.ts +284 -0
- package/es6/pdf-viewer-api/types.js +6 -0
- package/es6/pdf-viewer-canvas/CanvasEvents.d.ts +76 -0
- package/es6/pdf-viewer-canvas/CanvasEvents.js +345 -0
- package/es6/pdf-viewer-canvas/PdfViewerCanvas.d.ts +175 -0
- package/es6/pdf-viewer-canvas/PdfViewerCanvas.js +1226 -0
- package/es6/pdf-viewer-canvas/state/annotations.d.ts +36 -0
- package/es6/pdf-viewer-canvas/state/annotations.js +157 -0
- package/es6/pdf-viewer-canvas/state/appState.d.ts +10 -0
- package/es6/pdf-viewer-canvas/state/appState.js +60 -0
- package/es6/pdf-viewer-canvas/state/canvas.d.ts +31 -0
- package/es6/pdf-viewer-canvas/state/canvas.js +41 -0
- package/es6/pdf-viewer-canvas/state/document.d.ts +50 -0
- package/es6/pdf-viewer-canvas/state/document.js +99 -0
- package/es6/pdf-viewer-canvas/state/pointer.d.ts +31 -0
- package/es6/pdf-viewer-canvas/state/pointer.js +31 -0
- package/es6/pdf-viewer-canvas/state/scroll.d.ts +22 -0
- package/es6/pdf-viewer-canvas/state/scroll.js +25 -0
- package/es6/pdf-viewer-canvas/state/search.d.ts +36 -0
- package/es6/pdf-viewer-canvas/state/search.js +27 -0
- package/es6/pdf-viewer-canvas/state/store.d.ts +39 -0
- package/es6/pdf-viewer-canvas/state/store.js +52 -0
- package/es6/pdf-viewer-canvas/state/viewer.d.ts +91 -0
- package/es6/pdf-viewer-canvas/state/viewer.js +175 -0
- package/es6/pdf-viewer-canvas/view-layers/AnnotationSelectionLayer.d.ts +28 -0
- package/es6/pdf-viewer-canvas/view-layers/AnnotationSelectionLayer.js +452 -0
- package/es6/pdf-viewer-canvas/view-layers/BusyStateLayer.d.ts +9 -0
- package/es6/pdf-viewer-canvas/view-layers/BusyStateLayer.js +25 -0
- package/es6/pdf-viewer-canvas/view-layers/PdfDocumentLayer.d.ts +10 -0
- package/es6/pdf-viewer-canvas/view-layers/PdfDocumentLayer.js +149 -0
- package/es6/pdf-viewer-canvas/view-layers/ScrollLayer.d.ts +48 -0
- package/es6/pdf-viewer-canvas/view-layers/ScrollLayer.js +308 -0
- package/es6/pdf-viewer-canvas/view-layers/TextSelectionLayer.d.ts +19 -0
- package/es6/pdf-viewer-canvas/view-layers/TextSelectionLayer.js +289 -0
- package/es6/pdf-viewer-canvas/view-layers/ViewLayerBase.d.ts +31 -0
- package/es6/pdf-viewer-canvas/view-layers/ViewLayerBase.js +106 -0
- package/es6/pdf-viewer-canvas/view-layers/canvasShapes.d.ts +11 -0
- package/es6/pdf-viewer-canvas/view-layers/canvasShapes.js +149 -0
- package/es6/pdf-viewer-canvas/view-layers/canvasUtlis.d.ts +3 -0
- package/es6/pdf-viewer-canvas/view-layers/canvasUtlis.js +10 -0
- package/es6/pdf-viewer-canvas/view-layers/views/AnnotationBorder.d.ts +52 -0
- package/es6/pdf-viewer-canvas/view-layers/views/AnnotationBorder.js +377 -0
- package/es6/pdf-viewer-canvas/view-layers/views/AnnotationContextBar.d.ts +47 -0
- package/es6/pdf-viewer-canvas/view-layers/views/AnnotationContextBar.js +102 -0
- package/es6/pdf-viewer-canvas/view-layers/views/TextSelectionContextBar.d.ts +14 -0
- package/es6/pdf-viewer-canvas/view-layers/views/TextSelectionContextBar.js +36 -0
- package/es6/pdf-viewing/PdfViewing.d.ts +4865 -0
- package/es6/pdf-viewing/PdfViewing.js +9611 -0
- package/es6/pdf-web-viewer/PdfWebViewer.d.ts +372 -0
- package/es6/pdf-web-viewer/PdfWebViewer.js +1386 -0
- package/es6/pdf-web-viewer/UserSettings.d.ts +8 -0
- package/es6/pdf-web-viewer/UserSettings.js +40 -0
- package/es6/pdf-web-viewer/WebViewerOptions.d.ts +387 -0
- package/es6/pdf-web-viewer/WebViewerOptions.js +582 -0
- package/es6/pdf-web-viewer/state/index.d.ts +80 -0
- package/es6/pdf-web-viewer/state/index.js +98 -0
- package/es6/pdf-web-viewer/state/layout.d.ts +24 -0
- package/es6/pdf-web-viewer/state/layout.js +21 -0
- package/es6/pdf-web-viewer/state/mobile.d.ts +16 -0
- package/es6/pdf-web-viewer/state/mobile.js +11 -0
- package/es6/pdf-web-viewer/state/navigationPanel.d.ts +61 -0
- package/es6/pdf-web-viewer/state/navigationPanel.js +84 -0
- package/es6/pdf-web-viewer/state/passwordForm.d.ts +18 -0
- package/es6/pdf-web-viewer/state/passwordForm.js +21 -0
- package/es6/pdf-web-viewer/state/pdfDocument.d.ts +31 -0
- package/es6/pdf-web-viewer/state/pdfDocument.js +41 -0
- package/es6/pdf-web-viewer/state/search.d.ts +29 -0
- package/es6/pdf-web-viewer/state/search.js +23 -0
- package/es6/pdf-web-viewer/views/App.d.ts +4 -0
- package/es6/pdf-web-viewer/views/App.js +19 -0
- package/es6/pdf-web-viewer/views/CustomButtons.d.ts +9 -0
- package/es6/pdf-web-viewer/views/CustomButtons.js +18 -0
- package/es6/pdf-web-viewer/views/DropZone.d.ts +9 -0
- package/es6/pdf-web-viewer/views/DropZone.js +53 -0
- package/es6/pdf-web-viewer/views/Layout.d.ts +4 -0
- package/es6/pdf-web-viewer/views/Layout.js +22 -0
- package/es6/pdf-web-viewer/views/annotationbar/Annotationbar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/annotationbar/Annotationbar.js +21 -0
- package/es6/pdf-web-viewer/views/appbar/AddonsToolbar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/AddonsToolbar.js +35 -0
- package/es6/pdf-web-viewer/views/appbar/AnnotationsMenu.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/AnnotationsMenu.js +22 -0
- package/es6/pdf-web-viewer/views/appbar/AppBar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/AppBar.js +26 -0
- package/es6/pdf-web-viewer/views/appbar/DocumentBar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/DocumentBar.js +36 -0
- package/es6/pdf-web-viewer/views/appbar/Menu.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/Menu.js +80 -0
- package/es6/pdf-web-viewer/views/appbar/NavigationBar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/NavigationBar.js +74 -0
- package/es6/pdf-web-viewer/views/appbar/SearchBar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/SearchBar.js +83 -0
- package/es6/pdf-web-viewer/views/appbar/SearchOptions.d.ts +10 -0
- package/es6/pdf-web-viewer/views/appbar/SearchOptions.js +55 -0
- package/es6/pdf-web-viewer/views/appbar/ViewBar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/ViewBar.js +52 -0
- package/es6/pdf-web-viewer/views/appbar/ZoomBar.d.ts +4 -0
- package/es6/pdf-web-viewer/views/appbar/ZoomBar.js +18 -0
- package/es6/pdf-web-viewer/views/modal/ApplicationError.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/ApplicationError.js +25 -0
- package/es6/pdf-web-viewer/views/modal/LoadApplication.d.ts +3 -0
- package/es6/pdf-web-viewer/views/modal/LoadApplication.js +6 -0
- package/es6/pdf-web-viewer/views/modal/LoadFile.d.ts +3 -0
- package/es6/pdf-web-viewer/views/modal/LoadFile.js +10 -0
- package/es6/pdf-web-viewer/views/modal/Modal.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/Modal.js +39 -0
- package/es6/pdf-web-viewer/views/modal/OpenFile.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/OpenFile.js +30 -0
- package/es6/pdf-web-viewer/views/modal/OpenFileError.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/OpenFileError.js +13 -0
- package/es6/pdf-web-viewer/views/modal/PasswordForm.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/PasswordForm.js +54 -0
- package/es6/pdf-web-viewer/views/modal/SaveFile.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/SaveFile.js +10 -0
- package/es6/pdf-web-viewer/views/modal/UnsavedChanges.d.ts +4 -0
- package/es6/pdf-web-viewer/views/modal/UnsavedChanges.js +32 -0
- package/es6/pdf-web-viewer/views/navigation/AnnotationList.d.ts +8 -0
- package/es6/pdf-web-viewer/views/navigation/AnnotationList.js +26 -0
- package/es6/pdf-web-viewer/views/navigation/AnnotationListItem.d.ts +8 -0
- package/es6/pdf-web-viewer/views/navigation/AnnotationListItem.js +158 -0
- package/es6/pdf-web-viewer/views/navigation/AnnotationNavigation.d.ts +4 -0
- package/es6/pdf-web-viewer/views/navigation/AnnotationNavigation.js +11 -0
- package/es6/pdf-web-viewer/views/navigation/NavigationPanel.d.ts +4 -0
- package/es6/pdf-web-viewer/views/navigation/NavigationPanel.js +50 -0
- package/es6/pdf-web-viewer/views/navigation/OutlineList.d.ts +12 -0
- package/es6/pdf-web-viewer/views/navigation/OutlineList.js +19 -0
- package/es6/pdf-web-viewer/views/navigation/OutlineNavigation.d.ts +4 -0
- package/es6/pdf-web-viewer/views/navigation/OutlineNavigation.js +10 -0
- package/es6/pdf-web-viewer/views/navigation/ThumbnailNavigation.d.ts +16 -0
- package/es6/pdf-web-viewer/views/navigation/ThumbnailNavigation.js +32 -0
- package/package.json +24 -0
- package/pdfwebviewer/PdfViewing.data +0 -0
- package/pdfwebviewer/PdfViewing_Main.js +1 -0
- package/pdfwebviewer/PdfViewing_Main.wasm +0 -0
- package/pdfwebviewer/PdfViewing_Worker.js +1 -0
- package/pdfwebviewer/PdfViewing_Worker.wasm +0 -0
- package/pdfwebviewer/pdf-web-viewer.css +2407 -0
- package/pdfwebviewer/pdf-web-viewer.development.js +25955 -0
- package/pdfwebviewer/pdf-web-viewer.min.js +1 -0
- package/pdfwebviewer/translations.de.json +151 -0
- package/pdfwebviewer/translations.en.json +151 -0
- package/pdfwebviewer/translations.fr.json +151 -0
- package/pdfwebviewer/translations.it.json +151 -0
- package/scss/common/_breakpoints.scss +44 -0
- package/scss/common/_buttons.scss +42 -0
- package/scss/common/_colorpicker.scss +89 -0
- package/scss/common/_common.scss +21 -0
- package/scss/common/_contextbar.scss +44 -0
- package/scss/common/_dropdown.scss +176 -0
- package/scss/common/_icon.scss +9 -0
- package/scss/common/_index.scss +19 -0
- package/scss/common/_loader.scss +30 -0
- package/scss/common/_rangeslider.scss +24 -0
- package/scss/common/_scrollbars.scss +64 -0
- package/scss/common/_stroke-style-picker.scss +64 -0
- package/scss/common/_stroke-width-picker.scss +23 -0
- package/scss/common/_toolbar.scss +117 -0
- package/scss/common/_tooltip.scss +39 -0
- package/scss/modules/_eraser.scss +28 -0
- package/scss/modules/_forms.scss +56 -0
- package/scss/modules/_highlightannotation.scss +12 -0
- package/scss/modules/_index.scss +5 -0
- package/scss/modules/_inkannotation.scss +41 -0
- package/scss/modules/_stampannotation.scss +19 -0
- package/scss/pdf-viewer-canvas/_annotationborder.scss +107 -0
- package/scss/pdf-viewer-canvas/_busy-loader.scss +53 -0
- package/scss/pdf-viewer-canvas/_freetexteditor.scss +28 -0
- package/scss/pdf-viewer-canvas/_index.scss +7 -0
- package/scss/pdf-viewer-canvas/_layout.scss +52 -0
- package/scss/pdf-viewer-canvas/_popup.scss +217 -0
- package/scss/pdf-viewer-canvas/_printservice.scss +171 -0
- package/scss/pdf-viewer-canvas/_textselection.scss +17 -0
- package/scss/pdf-web-viewer/_annotationbar.scss +47 -0
- package/scss/pdf-web-viewer/_index.scss +8 -0
- package/scss/pdf-web-viewer/_layout.scss +63 -0
- package/scss/pdf-web-viewer/_modal.scss +186 -0
- package/scss/pdf-web-viewer/_navigationpanel.scss +398 -0
- package/scss/pdf-web-viewer/_searchbar.scss +47 -0
- package/scss/pdf-web-viewer/_toolbar.scss +134 -0
- package/scss/pdf-web-viewer/_viewer.scss +54 -0
- package/scss/pdf-web-viewer.scss +1 -0
- package/scss/themes/default/_light.scss +32 -0
- package/scss/themes/default/_mixins.scss +129 -0
- package/scss/themes/default/_theme.scss +161 -0
- package/scss/themes/pdf-web-viewer.scss +1 -0
- package/umd/pdf-web-viewer.development.js +25955 -0
- package/umd/pdf-web-viewer.development.js.map +1 -0
- package/umd/pdf-web-viewer.min.js +1 -0
- package/wasm/PdfViewing.data +0 -0
- package/wasm/PdfViewing_Main.js +1 -0
- package/wasm/PdfViewing_Main.wasm +0 -0
- package/wasm/PdfViewing_Worker.js +1 -0
- package/wasm/PdfViewing_Worker.wasm +0 -0
- package/wasm/translations.de.json +151 -0
- package/wasm/translations.en.json +151 -0
- package/wasm/translations.fr.json +151 -0
- package/wasm/translations.it.json +151 -0
|
@@ -0,0 +1,1386 @@
|
|
|
1
|
+
import { PdfViewing } from '../pdf-viewing/PdfViewing';
|
|
2
|
+
import { app } from '../lib/hyperapp';
|
|
3
|
+
import { App } from './views/App';
|
|
4
|
+
import { FileType, } from '../pdf-viewer-api/types';
|
|
5
|
+
import { PdfItemCategory, } from '../pdf-viewer-api';
|
|
6
|
+
import { PdfViewerCanvas } from '../pdf-viewer-canvas/PdfViewerCanvas';
|
|
7
|
+
import { createState, actions } from './state/index';
|
|
8
|
+
import { DeviceType, ScreenSize } from './state/layout';
|
|
9
|
+
import { translationManager } from '../common/TranslationManager';
|
|
10
|
+
import { tooltipManager } from '../common/TooltipManager';
|
|
11
|
+
import { ColorPaletteMap, OptionsToVerify, WebViewerOptions, } from './WebViewerOptions';
|
|
12
|
+
import { getKeyboardCommands } from '../common/utils';
|
|
13
|
+
export class PdfWebViewer {
|
|
14
|
+
constructor(containerElement, license, options) {
|
|
15
|
+
this.visiblePageRange = {
|
|
16
|
+
firstPage: 0,
|
|
17
|
+
lastPage: 0,
|
|
18
|
+
};
|
|
19
|
+
this.eventListeners = new Map();
|
|
20
|
+
this.loadThumbnailsQueue = [];
|
|
21
|
+
this.loadPageThumbnailsTimer = null;
|
|
22
|
+
this.metadata = {
|
|
23
|
+
version: '4.3.6',
|
|
24
|
+
type: 'stable',
|
|
25
|
+
};
|
|
26
|
+
if (!containerElement) {
|
|
27
|
+
throw { error: 'PdfWebViewer container element is null' };
|
|
28
|
+
}
|
|
29
|
+
this.licenseKey = license;
|
|
30
|
+
this.element = containerElement;
|
|
31
|
+
this.options = new WebViewerOptions(options);
|
|
32
|
+
if (options) {
|
|
33
|
+
this.verifyOptions(options, this.options);
|
|
34
|
+
}
|
|
35
|
+
this.handleKeyboardShortcuts = this.handleKeyboardShortcuts.bind(this);
|
|
36
|
+
this.createView = this.createView.bind(this);
|
|
37
|
+
this.loadPageThumbnails = this.loadPageThumbnails.bind(this);
|
|
38
|
+
this.loadDocumentOutlines = this.loadDocumentOutlines.bind(this);
|
|
39
|
+
this.handleAppLoaded = this.handleAppLoaded.bind(this);
|
|
40
|
+
this.handleResize = this.handleResize.bind(this);
|
|
41
|
+
this.getScreenSize = this.getScreenSize.bind(this);
|
|
42
|
+
this.handleDocumentOpened = this.handleDocumentOpened.bind(this);
|
|
43
|
+
this.handleDocumentClosed = this.handleDocumentClosed.bind(this);
|
|
44
|
+
this.handleFirstVisiblePageChanged = this.handleFirstVisiblePageChanged.bind(this);
|
|
45
|
+
this.handleLastVisiblePageChanged = this.handleLastVisiblePageChanged.bind(this);
|
|
46
|
+
this.handlePageNumberChanged = this.handlePageNumberChanged.bind(this);
|
|
47
|
+
this.handleZoomChanged = this.handleZoomChanged.bind(this);
|
|
48
|
+
this.handleRotationChanged = this.handleRotationChanged.bind(this);
|
|
49
|
+
this.handleFitModeChanged = this.handleFitModeChanged.bind(this);
|
|
50
|
+
this.handlePageLayoutModeChanged = this.handlePageLayoutModeChanged.bind(this);
|
|
51
|
+
this.handleBusyStateChanged = this.handleBusyStateChanged.bind(this);
|
|
52
|
+
this.handlePageChanged = this.handlePageChanged.bind(this);
|
|
53
|
+
this.handleTextSelected = this.handleTextSelected.bind(this);
|
|
54
|
+
this.handleError = this.handleError.bind(this);
|
|
55
|
+
this.addPagesToThumbnailsQueue = this.addPagesToThumbnailsQueue.bind(this);
|
|
56
|
+
this.handleAnnotationCreated = this.handleAnnotationCreated.bind(this);
|
|
57
|
+
this.handleAnnotationUpdated = this.handleAnnotationUpdated.bind(this);
|
|
58
|
+
this.handleAnnotationDeleted = this.handleAnnotationDeleted.bind(this);
|
|
59
|
+
this.handleAnnotationSelected = this.handleAnnotationSelected.bind(this);
|
|
60
|
+
this.handleAnnotationDeselected = this.handleAnnotationDeselected.bind(this);
|
|
61
|
+
this.showUnconfirmedChangesDialog = this.showUnconfirmedChangesDialog.bind(this);
|
|
62
|
+
document.addEventListener('keydown', this.handleKeyboardShortcuts, false);
|
|
63
|
+
const resizeObserver = new ResizeObserver(this.handleResize);
|
|
64
|
+
resizeObserver.observe(this.element);
|
|
65
|
+
tooltipManager.setType(this.options.viewer.general.tooltips || 'title');
|
|
66
|
+
const initialState = createState(this.options);
|
|
67
|
+
initialState.layout.deviceType = /iPhone|iPad|iPod|Android|mobile/i.test(navigator.userAgent)
|
|
68
|
+
? DeviceType.Mobile
|
|
69
|
+
: DeviceType.Desktop;
|
|
70
|
+
initialState.layout.screenSize = this.getScreenSize();
|
|
71
|
+
this.view = this.createView(app)(initialState, actions, App, this.element);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Open a PDF and optionally one or more associated FDFs.
|
|
75
|
+
* @param pdfFile
|
|
76
|
+
* The PDF file to be opened.
|
|
77
|
+
* @param fdfFiles
|
|
78
|
+
* An array of FDF files to be opened jointly with the PDF.
|
|
79
|
+
* Set to `null` if no FDF files need to be opened.
|
|
80
|
+
* @param password
|
|
81
|
+
* The password used for opening the PDF.
|
|
82
|
+
* Set to `null` if the PDF is not encrypted.
|
|
83
|
+
* @param renderOptions
|
|
84
|
+
* Options used for rendering pages.
|
|
85
|
+
* @param viewOptions
|
|
86
|
+
* Options used for configuring the view
|
|
87
|
+
* @returns
|
|
88
|
+
* void
|
|
89
|
+
*/
|
|
90
|
+
open(pdfFile, fdfFiles, password, viewOptions, renderOptions) {
|
|
91
|
+
var _a;
|
|
92
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.api.open({
|
|
93
|
+
pdfFile,
|
|
94
|
+
fdfFiles,
|
|
95
|
+
password,
|
|
96
|
+
viewOptions,
|
|
97
|
+
renderOptions,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated Deprecated in Version 3.10. Use save method instead.
|
|
102
|
+
*/
|
|
103
|
+
openFile(file, password, pdfAuthorization) {
|
|
104
|
+
let inputFile = undefined;
|
|
105
|
+
if (typeof file === 'string') {
|
|
106
|
+
inputFile = { uri: file };
|
|
107
|
+
if (pdfAuthorization) {
|
|
108
|
+
inputFile.httpOptions = {
|
|
109
|
+
headers: {
|
|
110
|
+
Authorization: pdfAuthorization,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
inputFile = { data: file };
|
|
117
|
+
}
|
|
118
|
+
this.open(inputFile, null, password);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated Deprecated in Version 3.10. Use save method instead.
|
|
122
|
+
*/
|
|
123
|
+
openFDF(pdfFile, fdfFile, password, pdfAuthorization, fdfAuthorization) {
|
|
124
|
+
let pdfInputFile = undefined;
|
|
125
|
+
if (typeof pdfFile === 'string') {
|
|
126
|
+
pdfInputFile = { uri: pdfFile };
|
|
127
|
+
if (pdfAuthorization) {
|
|
128
|
+
pdfInputFile.httpOptions = {
|
|
129
|
+
headers: {
|
|
130
|
+
Authorization: pdfAuthorization,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
pdfInputFile = { data: pdfFile };
|
|
137
|
+
}
|
|
138
|
+
const fdfInputFile = typeof fdfFile === 'string'
|
|
139
|
+
? { uri: fdfFile }
|
|
140
|
+
: { data: fdfFile };
|
|
141
|
+
this.open(pdfInputFile, [fdfInputFile], password);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Return the opened PDF as binary data,
|
|
145
|
+
* to be used, e.g., to save the file to disk.
|
|
146
|
+
* @param saveOptions
|
|
147
|
+
* Options for saving the document
|
|
148
|
+
* @returns
|
|
149
|
+
* A Promise with an Blob containing the data or null if no document is open
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
save(saveOptions) {
|
|
153
|
+
return this.viewerCanvas ? this.viewerCanvas.save(saveOptions) : null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Deprecated in Version 3.10. Use save method instead.
|
|
157
|
+
*/
|
|
158
|
+
saveFile(asFdf) {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
var _a;
|
|
161
|
+
const fileType = asFdf ? FileType.Fdf : FileType.Pdf;
|
|
162
|
+
(_a = this.save({ fileType })) === null || _a === void 0 ? void 0 : _a.then((blob) => {
|
|
163
|
+
resolve(blob.arrayBuffer());
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* saves the currently opened PDF file to the local file system
|
|
169
|
+
*/
|
|
170
|
+
downloadFile(saveOptions) {
|
|
171
|
+
if (this.view) {
|
|
172
|
+
return this.view.api.downloadFile(saveOptions);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Close the currently opened PDF file.
|
|
177
|
+
*/
|
|
178
|
+
close() {
|
|
179
|
+
if (this.view) {
|
|
180
|
+
return this.view.api.close();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* dispose the PdfWebViewer.
|
|
185
|
+
*/
|
|
186
|
+
destroy() {
|
|
187
|
+
var _a;
|
|
188
|
+
// remove all event listeners
|
|
189
|
+
document.removeEventListener('keydown', this.handleKeyboardShortcuts, false);
|
|
190
|
+
this.eventListeners.clear();
|
|
191
|
+
if (this.viewerCanvas) {
|
|
192
|
+
this.viewerCanvas.removeEventListener('appLoaded', this.handleAppLoaded);
|
|
193
|
+
this.viewerCanvas.removeEventListener('firstVisiblePage', this.handleFirstVisiblePageChanged);
|
|
194
|
+
this.viewerCanvas.removeEventListener('lastVisiblePage', this.handleLastVisiblePageChanged);
|
|
195
|
+
this.viewerCanvas.removeEventListener('pageNumber', this.handlePageNumberChanged);
|
|
196
|
+
this.viewerCanvas.removeEventListener('zoom', this.handleZoomChanged);
|
|
197
|
+
this.viewerCanvas.removeEventListener('fitMode', this.handleFitModeChanged);
|
|
198
|
+
this.viewerCanvas.removeEventListener('pageLayoutMode', this.handlePageLayoutModeChanged);
|
|
199
|
+
this.viewerCanvas.removeEventListener('busyState', this.handleBusyStateChanged);
|
|
200
|
+
this.viewerCanvas.removeEventListener('rotation', this.handleRotationChanged);
|
|
201
|
+
this.viewerCanvas.removeEventListener('pageChanged', this.handlePageChanged);
|
|
202
|
+
this.viewerCanvas.removeEventListener('error', this.handleError);
|
|
203
|
+
this.viewerCanvas.removeEventListener('itemCreated', this.handleAnnotationCreated);
|
|
204
|
+
this.viewerCanvas.removeEventListener('itemUpdated', this.handleAnnotationUpdated);
|
|
205
|
+
this.viewerCanvas.removeEventListener('itemDeleted', this.handleAnnotationDeleted);
|
|
206
|
+
this.viewerCanvas.removeEventListener('itemSelected', this.handleAnnotationSelected);
|
|
207
|
+
this.viewerCanvas.removeEventListener('itemDeselected', this.handleAnnotationDeselected);
|
|
208
|
+
}
|
|
209
|
+
// destroy viewer canvas
|
|
210
|
+
(_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
211
|
+
this.viewerCanvas = undefined;
|
|
212
|
+
this.view = undefined;
|
|
213
|
+
this.loadThumbnailsQueue = [];
|
|
214
|
+
if (this.loadPageThumbnailsTimer) {
|
|
215
|
+
clearTimeout(this.loadPageThumbnailsTimer);
|
|
216
|
+
}
|
|
217
|
+
// remove all child elements
|
|
218
|
+
while (this.element.firstChild) {
|
|
219
|
+
this.element.removeChild(this.element.firstChild);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get the total page count of the opened document.
|
|
224
|
+
* @returns
|
|
225
|
+
* The total number of pages of the currently opened file.
|
|
226
|
+
* Returns null if no document is open
|
|
227
|
+
*/
|
|
228
|
+
getPageCount() {
|
|
229
|
+
return this.viewerCanvas ? this.viewerCanvas.getPageCount() : null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the currently most visible page.
|
|
233
|
+
* @returns
|
|
234
|
+
* The number of the page which covers most area on the view port.
|
|
235
|
+
* If multiple pages cover the same amount of space,
|
|
236
|
+
* the one with smaller page number is returned.
|
|
237
|
+
* Returns null if no document is open
|
|
238
|
+
*/
|
|
239
|
+
getPageNumber() {
|
|
240
|
+
if (this.viewerCanvas) {
|
|
241
|
+
return this.viewerCanvas.getPageNumber();
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Sets the first currently visible page.
|
|
247
|
+
* @param pageNumber
|
|
248
|
+
* The number of the page to be displayed
|
|
249
|
+
*/
|
|
250
|
+
setPageNumber(pageNumber) {
|
|
251
|
+
if (this.viewerCanvas) {
|
|
252
|
+
this.viewerCanvas.setPageNumber(pageNumber);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Rotates a page 90 degrees either clockwise or counterclockwise
|
|
257
|
+
*
|
|
258
|
+
* @param pageNumber
|
|
259
|
+
* The number of the page to be rotated
|
|
260
|
+
* @param direction
|
|
261
|
+
* Specifies whether the rotation is clockwise or counterclockwise.
|
|
262
|
+
*/
|
|
263
|
+
rotatePage(pageNumber, direction) {
|
|
264
|
+
if (this.viewerCanvas) {
|
|
265
|
+
this.viewerCanvas.rotatePage(pageNumber, direction);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Go to the next page.
|
|
270
|
+
*/
|
|
271
|
+
nextPage() {
|
|
272
|
+
if (this.viewerCanvas) {
|
|
273
|
+
this.viewerCanvas.nextPage();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Go to the previousPage page.
|
|
278
|
+
*/
|
|
279
|
+
previousPage() {
|
|
280
|
+
if (this.viewerCanvas) {
|
|
281
|
+
this.viewerCanvas.previousPage();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Get the viewer zoom.
|
|
286
|
+
* @returns
|
|
287
|
+
* The currently used zoom factor.
|
|
288
|
+
* Returns null if no document is open.
|
|
289
|
+
*/
|
|
290
|
+
getZoom() {
|
|
291
|
+
if (this.viewerCanvas) {
|
|
292
|
+
return this.viewerCanvas.getZoom();
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Set the viewer zoom.
|
|
298
|
+
* @param zoom
|
|
299
|
+
* The zoom factor as a percentage of the original size.
|
|
300
|
+
*/
|
|
301
|
+
setZoom(zoom) {
|
|
302
|
+
if (this.viewerCanvas) {
|
|
303
|
+
this.viewerCanvas.setZoom(zoom);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Sets the zoom to the closest higher predefined zoom Level.
|
|
308
|
+
*/
|
|
309
|
+
zoomIn() {
|
|
310
|
+
var _a;
|
|
311
|
+
(_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.zoomIn();
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Sets the zoom to the closest smaller predefined zoom Level.
|
|
315
|
+
*/
|
|
316
|
+
zoomOut() {
|
|
317
|
+
var _a;
|
|
318
|
+
(_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.zoomOut();
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Get the current fit mode.
|
|
322
|
+
* @returns
|
|
323
|
+
* The mode that is currently used for fitting the viewport to the visible pages.
|
|
324
|
+
* Returns null if no document is open.
|
|
325
|
+
*/
|
|
326
|
+
getFitMode() {
|
|
327
|
+
if (this.viewerCanvas) {
|
|
328
|
+
return this.viewerCanvas.getFitMode();
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Set the fit mode.
|
|
334
|
+
* @param fitMode
|
|
335
|
+
* The mode to be used for fitting the viewport to the visible pages.
|
|
336
|
+
*/
|
|
337
|
+
setFitMode(fitMode) {
|
|
338
|
+
if (this.viewerCanvas) {
|
|
339
|
+
this.viewerCanvas.setFitMode(fitMode);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Get the current page layout mode.
|
|
344
|
+
* @returns
|
|
345
|
+
* The mode that is currently used for arranging pages on the canvas.
|
|
346
|
+
* Returns null if no document is open.
|
|
347
|
+
*/
|
|
348
|
+
getPageLayoutMode() {
|
|
349
|
+
if (this.viewerCanvas) {
|
|
350
|
+
return this.viewerCanvas.getPageLayoutMode();
|
|
351
|
+
}
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Set the page layout mode.
|
|
356
|
+
* @param pageLayoutMode
|
|
357
|
+
* The mode to be used for arranging pages on the canvas.
|
|
358
|
+
*/
|
|
359
|
+
setPageLayoutMode(pageLayoutMode) {
|
|
360
|
+
if (this.viewerCanvas) {
|
|
361
|
+
this.viewerCanvas.setPageLayoutMode(pageLayoutMode);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Get the viewer rotation.
|
|
366
|
+
* @returns
|
|
367
|
+
* The currently used viewer rotation on all pages.
|
|
368
|
+
* Returns null if no document is open
|
|
369
|
+
*/
|
|
370
|
+
getRotation() {
|
|
371
|
+
if (this.viewerCanvas) {
|
|
372
|
+
return this.viewerCanvas.getRotation();
|
|
373
|
+
}
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Set the viewer rotation.
|
|
378
|
+
* NOTE: This only changes the view of the document and is not an operation on the document.
|
|
379
|
+
* @param rotation
|
|
380
|
+
* The rotation to be applied on all pages (cumulative with the embedded rotation per page).
|
|
381
|
+
*/
|
|
382
|
+
setRotation(rotation) {
|
|
383
|
+
if (this.viewerCanvas) {
|
|
384
|
+
this.viewerCanvas.setRotation(rotation);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Get the product version of the viewer.
|
|
389
|
+
* @returns
|
|
390
|
+
* The product version of the PDF Web Viewer.
|
|
391
|
+
*/
|
|
392
|
+
getProductVersion() {
|
|
393
|
+
return PdfViewing.Sdk.version;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Get the metadata of the viewer.
|
|
397
|
+
* @returns
|
|
398
|
+
* The metadata of the PDF Web Viewer.
|
|
399
|
+
*/
|
|
400
|
+
getMetadata() {
|
|
401
|
+
return this.metadata;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Check whether there are unsaved changes in the document.
|
|
405
|
+
* @returns
|
|
406
|
+
* A DocumentChange enum indicating what kind of changes were made
|
|
407
|
+
* Returns null if no document is open
|
|
408
|
+
*/
|
|
409
|
+
hasChanges() {
|
|
410
|
+
if (this.view) {
|
|
411
|
+
return this.view.api.hasChanges();
|
|
412
|
+
}
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Opens the information pane and selects the given pane
|
|
417
|
+
* @selectedPane
|
|
418
|
+
* Name of the pane thath should be displayed
|
|
419
|
+
*/
|
|
420
|
+
showInformationPane(selectedPane) {
|
|
421
|
+
if (this.view) {
|
|
422
|
+
if (selectedPane) {
|
|
423
|
+
this.view.navigationPanel.selectNavigation(selectedPane);
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
this.view.navigationPanel.showNavigationPanel();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Closes the information pane
|
|
432
|
+
*/
|
|
433
|
+
hideInformationPane() {
|
|
434
|
+
if (this.view) {
|
|
435
|
+
this.view.navigationPanel.hideNavigationPanel();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Toggle the information pane
|
|
440
|
+
*/
|
|
441
|
+
toggleInformationPane() {
|
|
442
|
+
if (this.view) {
|
|
443
|
+
this.view.navigationPanel.toggleNavigationPanel();
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Opens the search tool bar and starts a new search with the given text
|
|
448
|
+
* @param text
|
|
449
|
+
* text to be searched for
|
|
450
|
+
* @param searchOptions
|
|
451
|
+
* Options for be used for searching
|
|
452
|
+
*/
|
|
453
|
+
startSearch(searchString, searchOptions) {
|
|
454
|
+
if (this.view && this.viewerCanvas) {
|
|
455
|
+
const { startPage, isCaseSensitive, isWrappingEnabled, isRegex, hideToolbar } = searchOptions || {};
|
|
456
|
+
const caseSensitive = Boolean(isCaseSensitive);
|
|
457
|
+
const wrappingEnabled = Boolean(isWrappingEnabled);
|
|
458
|
+
const regex = Boolean(isRegex);
|
|
459
|
+
if (!hideToolbar) {
|
|
460
|
+
this.view.search.openSearch();
|
|
461
|
+
this.view.search.updateToSearch(searchString);
|
|
462
|
+
this.view.search.setCaseSensitive(caseSensitive);
|
|
463
|
+
this.view.search.setWrappingSearch(wrappingEnabled);
|
|
464
|
+
this.view.search.setRegex(regex);
|
|
465
|
+
}
|
|
466
|
+
this.viewerCanvas.startSearch(searchString, startPage || 1, caseSensitive, wrappingEnabled, regex);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Highlights the next search result
|
|
471
|
+
*/
|
|
472
|
+
nextSearchMatch() {
|
|
473
|
+
if (this.viewerCanvas) {
|
|
474
|
+
this.viewerCanvas.nextSearchMatch();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Highlights the previous search result
|
|
479
|
+
*/
|
|
480
|
+
previousSearchMatch() {
|
|
481
|
+
if (this.viewerCanvas) {
|
|
482
|
+
this.viewerCanvas.previousSearchMatch();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Stops the current search and closes the search tool bar
|
|
487
|
+
*/
|
|
488
|
+
endSearch() {
|
|
489
|
+
if (this.view) {
|
|
490
|
+
this.view.api.endSearch();
|
|
491
|
+
this.view.search.closeSearch();
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Opens the print dialog
|
|
496
|
+
*/
|
|
497
|
+
print() {
|
|
498
|
+
var _a;
|
|
499
|
+
(_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.print();
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Returns the selected text
|
|
503
|
+
*/
|
|
504
|
+
getSelectedText() {
|
|
505
|
+
var _a, _b;
|
|
506
|
+
return (_b = (_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.getSelectedText()) !== null && _b !== void 0 ? _b : '';
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Register a function that will be called whenever the specified event is delivered
|
|
510
|
+
* @param type
|
|
511
|
+
* String representing the event type to listen for.
|
|
512
|
+
* @param listener
|
|
513
|
+
* The function that will be executet when an event of the specified type occurs
|
|
514
|
+
*/
|
|
515
|
+
addEventListener(type, listener) {
|
|
516
|
+
if (this.eventListeners.has(type)) {
|
|
517
|
+
;
|
|
518
|
+
this.eventListeners.get(type).push(listener);
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
this.eventListeners.set(type, [listener]);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Removes an event listener previously registered with addEventListener
|
|
526
|
+
* @param type
|
|
527
|
+
* String representing the event for which to remove an event listener.
|
|
528
|
+
* @param listener
|
|
529
|
+
* The event listener function of the event handler to remove from the event target.
|
|
530
|
+
*/
|
|
531
|
+
removeEventListener(type, listener) {
|
|
532
|
+
if (this.eventListeners.has(type)) {
|
|
533
|
+
let listeners = this.eventListeners.get(type);
|
|
534
|
+
listeners = listeners.filter((listenerInArray) => listenerInArray !== listener);
|
|
535
|
+
if (listeners.length !== 0) {
|
|
536
|
+
this.eventListeners.set(type, listeners);
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
this.eventListeners.delete(type);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
dispatchEvent(type, args) {
|
|
544
|
+
if (this.eventListeners.has(type)) {
|
|
545
|
+
const listeners = this.eventListeners.get(type);
|
|
546
|
+
listeners.forEach((listener) => listener(args));
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
createView(nextApp) {
|
|
550
|
+
return (state, a, view, element) => {
|
|
551
|
+
a.initialize = () => {
|
|
552
|
+
const loadTranslationPromise = translationManager.loadTranslations(this.options.viewer.general.language || 'en');
|
|
553
|
+
Promise.all([window.PdfToolsPromise, loadTranslationPromise])
|
|
554
|
+
.then(() => {
|
|
555
|
+
var _a;
|
|
556
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.loadScriptsCompleted();
|
|
557
|
+
})
|
|
558
|
+
.catch((err) => {
|
|
559
|
+
this.handleError(err);
|
|
560
|
+
});
|
|
561
|
+
};
|
|
562
|
+
a.createCanvasView = (elm) => {
|
|
563
|
+
try {
|
|
564
|
+
this.viewerCanvas = new PdfViewerCanvas(elm, this.licenseKey, this.options);
|
|
565
|
+
}
|
|
566
|
+
catch (err) {
|
|
567
|
+
this.handleError(err);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
this.viewerCanvas.addEventListener('appLoaded', this.handleAppLoaded);
|
|
571
|
+
this.viewerCanvas.addEventListener('firstVisiblePage', this.handleFirstVisiblePageChanged);
|
|
572
|
+
this.viewerCanvas.addEventListener('lastVisiblePage', this.handleLastVisiblePageChanged);
|
|
573
|
+
this.viewerCanvas.addEventListener('pageNumber', this.handlePageNumberChanged);
|
|
574
|
+
this.viewerCanvas.addEventListener('zoom', this.handleZoomChanged);
|
|
575
|
+
this.viewerCanvas.addEventListener('fitMode', this.handleFitModeChanged);
|
|
576
|
+
this.viewerCanvas.addEventListener('rotation', this.handleRotationChanged);
|
|
577
|
+
this.viewerCanvas.addEventListener('pageLayoutMode', this.handlePageLayoutModeChanged);
|
|
578
|
+
this.viewerCanvas.addEventListener('busyState', this.handleBusyStateChanged);
|
|
579
|
+
this.viewerCanvas.addEventListener('pageChanged', this.handlePageChanged);
|
|
580
|
+
this.viewerCanvas.addEventListener('textSelected', this.handleTextSelected);
|
|
581
|
+
this.viewerCanvas.addEventListener('error', this.handleError);
|
|
582
|
+
/*** annotation events */
|
|
583
|
+
this.viewerCanvas.addEventListener('itemCreated', this.handleAnnotationCreated);
|
|
584
|
+
this.viewerCanvas.addEventListener('itemUpdated', this.handleAnnotationUpdated);
|
|
585
|
+
this.viewerCanvas.addEventListener('itemDeleted', this.handleAnnotationDeleted);
|
|
586
|
+
this.viewerCanvas.addEventListener('itemSelected', this.handleAnnotationSelected);
|
|
587
|
+
this.viewerCanvas.addEventListener('itemDeselected', this.handleAnnotationDeselected);
|
|
588
|
+
const params = new URLSearchParams(location.search);
|
|
589
|
+
if (params) {
|
|
590
|
+
const pdfUrl = params.get('url');
|
|
591
|
+
if (pdfUrl) {
|
|
592
|
+
this.open({ uri: pdfUrl, sourceTag: '' });
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
a.removeCanvasView = (elm) => {
|
|
597
|
+
if (this.viewerCanvas) {
|
|
598
|
+
this.viewerCanvas.removeEventListener('firstVisiblePage', this.handleFirstVisiblePageChanged);
|
|
599
|
+
this.viewerCanvas.removeEventListener('lastVisiblePage', this.handleLastVisiblePageChanged);
|
|
600
|
+
this.viewerCanvas.removeEventListener(`pageNumber`, this.handlePageNumberChanged);
|
|
601
|
+
this.viewerCanvas.removeEventListener('zoom', this.handleZoomChanged);
|
|
602
|
+
this.viewerCanvas.removeEventListener('fitMode', this.handleFitModeChanged);
|
|
603
|
+
this.viewerCanvas.removeEventListener('pageLayoutMode', this.handlePageLayoutModeChanged);
|
|
604
|
+
this.viewerCanvas.removeEventListener('busyState', this.handleBusyStateChanged);
|
|
605
|
+
this.viewerCanvas.removeEventListener('error', this.handleError);
|
|
606
|
+
this.viewerCanvas = undefined;
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
a.api = {
|
|
610
|
+
open: (args) => {
|
|
611
|
+
if (this.view) {
|
|
612
|
+
this.view.loadDocumentBegin();
|
|
613
|
+
if (this.viewerCanvas) {
|
|
614
|
+
if (!this.beforeOpen(args)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
if (this.viewerCanvas) {
|
|
618
|
+
this.viewerCanvas
|
|
619
|
+
.open(args.pdfFile, args.fdfFiles, args.password, args.viewOptions, args.renderOptions)
|
|
620
|
+
.then(() => {
|
|
621
|
+
this.openResolve(args);
|
|
622
|
+
})
|
|
623
|
+
.catch((error) => {
|
|
624
|
+
this.openReject(args, error);
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
close: () => {
|
|
631
|
+
if (this.view && this.viewerCanvas) {
|
|
632
|
+
if (this.showUnconfirmedChangesDialog()) {
|
|
633
|
+
this.view.showConfirmUnsavedChangesDialog(null, this.handleDocumentClosed);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
this.handleDocumentClosed();
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
downloadFile: (saveOptions) => {
|
|
640
|
+
return new Promise((resolve, reject) => {
|
|
641
|
+
if (this.view && this.viewerCanvas) {
|
|
642
|
+
this.view.saveDocumentBegin();
|
|
643
|
+
const viewState = this.view.getState();
|
|
644
|
+
const filename = viewState.pdfDocument.filename;
|
|
645
|
+
const mimetype = viewState.pdfDocument.mimetype;
|
|
646
|
+
this.viewerCanvas
|
|
647
|
+
.save(saveOptions)
|
|
648
|
+
.then((data) => {
|
|
649
|
+
const newBlob = new Blob([data], { type: mimetype });
|
|
650
|
+
const dataUrl = window.URL.createObjectURL(newBlob);
|
|
651
|
+
const link = document.createElement('a');
|
|
652
|
+
link.style.position = 'absolute';
|
|
653
|
+
link.style.left = '-1000px';
|
|
654
|
+
link.href = dataUrl;
|
|
655
|
+
link.download = filename || 'download.pdf';
|
|
656
|
+
this.element.appendChild(link);
|
|
657
|
+
link.click();
|
|
658
|
+
setTimeout(() => {
|
|
659
|
+
var _a;
|
|
660
|
+
this.element.removeChild(link);
|
|
661
|
+
window.URL.revokeObjectURL(dataUrl);
|
|
662
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.saveDocumentFulfilled();
|
|
663
|
+
}, 100);
|
|
664
|
+
resolve();
|
|
665
|
+
})
|
|
666
|
+
.catch((error) => {
|
|
667
|
+
var _a;
|
|
668
|
+
console.error(error);
|
|
669
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.saveDocumentRejected(error);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
},
|
|
674
|
+
hasChanges: () => {
|
|
675
|
+
if (this.viewerCanvas) {
|
|
676
|
+
return this.viewerCanvas.hasChanges();
|
|
677
|
+
}
|
|
678
|
+
return null;
|
|
679
|
+
},
|
|
680
|
+
setZoom: (zoom) => {
|
|
681
|
+
if (this.viewerCanvas) {
|
|
682
|
+
this.viewerCanvas.setZoom(zoom / 100);
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
getZoom: () => {
|
|
686
|
+
if (this.viewerCanvas) {
|
|
687
|
+
return this.viewerCanvas.getZoom();
|
|
688
|
+
}
|
|
689
|
+
return null;
|
|
690
|
+
},
|
|
691
|
+
zoomIn: () => {
|
|
692
|
+
if (this.viewerCanvas) {
|
|
693
|
+
this.viewerCanvas.zoomIn();
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
zoomOut: () => {
|
|
697
|
+
if (this.viewerCanvas) {
|
|
698
|
+
this.viewerCanvas.zoomOut();
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
setPageNumber: (page) => {
|
|
702
|
+
if (this.viewerCanvas) {
|
|
703
|
+
this.viewerCanvas.setPageNumber(page);
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
getPageNumber: () => {
|
|
707
|
+
if (this.viewerCanvas) {
|
|
708
|
+
return this.viewerCanvas.getPageNumber();
|
|
709
|
+
}
|
|
710
|
+
return null;
|
|
711
|
+
},
|
|
712
|
+
getPageCount: () => {
|
|
713
|
+
if (this.viewerCanvas) {
|
|
714
|
+
return this.viewerCanvas.getPageCount();
|
|
715
|
+
}
|
|
716
|
+
return null;
|
|
717
|
+
},
|
|
718
|
+
nextPage: () => {
|
|
719
|
+
if (this.viewerCanvas) {
|
|
720
|
+
this.viewerCanvas.nextPage();
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
previousPage: () => {
|
|
724
|
+
if (this.viewerCanvas) {
|
|
725
|
+
this.viewerCanvas.previousPage();
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
setFitMode: (fitMode) => {
|
|
729
|
+
if (this.viewerCanvas) {
|
|
730
|
+
this.viewerCanvas.setFitMode(fitMode);
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
getFitMode: () => {
|
|
734
|
+
if (this.viewerCanvas) {
|
|
735
|
+
return this.viewerCanvas.getFitMode();
|
|
736
|
+
}
|
|
737
|
+
return null;
|
|
738
|
+
},
|
|
739
|
+
setPageLayoutMode: (layoutMode) => {
|
|
740
|
+
if (this.viewerCanvas) {
|
|
741
|
+
this.viewerCanvas.setPageLayoutMode(layoutMode);
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
getPageLayoutMode: () => {
|
|
745
|
+
if (this.viewerCanvas) {
|
|
746
|
+
return this.viewerCanvas.getPageLayoutMode();
|
|
747
|
+
}
|
|
748
|
+
return null;
|
|
749
|
+
},
|
|
750
|
+
rotatePage: (pageRotation) => {
|
|
751
|
+
if (this.viewerCanvas) {
|
|
752
|
+
return this.viewerCanvas.rotatePage(pageRotation.page, pageRotation.direction);
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
rotate: () => {
|
|
756
|
+
if (this.viewerCanvas) {
|
|
757
|
+
const r = this.viewerCanvas.getRotation();
|
|
758
|
+
const rotation = r >= 270 ? 0 : r + 90;
|
|
759
|
+
this.viewerCanvas.setRotation(rotation);
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
setRotation: (rotation) => {
|
|
763
|
+
if (this.viewerCanvas) {
|
|
764
|
+
this.viewerCanvas.setRotation(rotation);
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
getRotation: () => {
|
|
768
|
+
if (this.viewerCanvas) {
|
|
769
|
+
return this.viewerCanvas.getRotation();
|
|
770
|
+
}
|
|
771
|
+
return null;
|
|
772
|
+
},
|
|
773
|
+
startSearch: () => {
|
|
774
|
+
if (this.view && this.viewerCanvas) {
|
|
775
|
+
const s = this.view.getState().search;
|
|
776
|
+
this.viewerCanvas.startSearch(s.searchString, 1, s.caseSensitive, s.wrapSearch, s.useRegex);
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
nextSearchMatch: () => {
|
|
780
|
+
if (this.viewerCanvas) {
|
|
781
|
+
this.viewerCanvas.nextSearchMatch();
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
previousSearchMatch: () => {
|
|
785
|
+
if (this.viewerCanvas) {
|
|
786
|
+
this.viewerCanvas.previousSearchMatch();
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
endSearch: () => {
|
|
790
|
+
if (this.viewerCanvas) {
|
|
791
|
+
this.viewerCanvas.endSearch();
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
updateCanvasSearchState: (state) => {
|
|
795
|
+
if (this.viewerCanvas) {
|
|
796
|
+
this.viewerCanvas.updateCanvasSearchState(state);
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
goTo: (pdfDestination) => {
|
|
800
|
+
if (this.viewerCanvas) {
|
|
801
|
+
this.viewerCanvas.goTo(pdfDestination);
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
goToAnnotation: (target) => {
|
|
805
|
+
if (this.viewerCanvas) {
|
|
806
|
+
if (target.annotation.isHidden()) {
|
|
807
|
+
this.handleAnnotationSelected(target.annotation);
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
try {
|
|
811
|
+
this.viewerCanvas.goToAnnotation(target.annotation, target.action);
|
|
812
|
+
}
|
|
813
|
+
catch (err) {
|
|
814
|
+
console.error(err);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
resetViewerMode: (pdfDestination) => {
|
|
820
|
+
if (this.viewerCanvas) {
|
|
821
|
+
this.viewerCanvas.resetViewerMode();
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
loadNavigationItems: () => {
|
|
825
|
+
if (this.view) {
|
|
826
|
+
this.loadPageThumbnails();
|
|
827
|
+
this.loadAnnotations();
|
|
828
|
+
const viewState = this.view.getState();
|
|
829
|
+
if (!viewState.navigationPanel.outlineItemsLoaded) {
|
|
830
|
+
this.loadDocumentOutlines();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
addPageRangeToThumbnailsQueue: (pageRange) => {
|
|
835
|
+
this.addPagesToThumbnailsQueue(pageRange.from, pageRange.to);
|
|
836
|
+
},
|
|
837
|
+
print: () => {
|
|
838
|
+
if (this.viewerCanvas) {
|
|
839
|
+
this.viewerCanvas.print();
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
activateModule: (moduleName, args) => {
|
|
843
|
+
if (this.viewerCanvas) {
|
|
844
|
+
this.viewerCanvas.activateModule(moduleName, args);
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
deactivateModule: (moduleName) => {
|
|
848
|
+
if (this.viewerCanvas) {
|
|
849
|
+
this.viewerCanvas.deactivateModule(moduleName);
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
};
|
|
853
|
+
a.initialize();
|
|
854
|
+
return nextApp(state, a, view, element);
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
getScreenSize() {
|
|
858
|
+
var _a;
|
|
859
|
+
const widthToScreenSize = (width) => {
|
|
860
|
+
if (width <= ScreenSize.Small) {
|
|
861
|
+
return ScreenSize.Small;
|
|
862
|
+
}
|
|
863
|
+
if (width <= ScreenSize.Medium) {
|
|
864
|
+
return ScreenSize.Medium;
|
|
865
|
+
}
|
|
866
|
+
return ScreenSize.Large;
|
|
867
|
+
};
|
|
868
|
+
const viewerElm = this.element.firstChild;
|
|
869
|
+
if (!this.view || !viewerElm) {
|
|
870
|
+
return widthToScreenSize(this.element.getBoundingClientRect().width);
|
|
871
|
+
}
|
|
872
|
+
if (viewerElm.offsetWidth && viewerElm.offsetHeight && viewerElm.getClientRects().length) {
|
|
873
|
+
return widthToScreenSize(viewerElm.getBoundingClientRect().width);
|
|
874
|
+
}
|
|
875
|
+
return (_a = this.view) === null || _a === void 0 ? void 0 : _a.getState().layout.screenSize;
|
|
876
|
+
}
|
|
877
|
+
handleResize() {
|
|
878
|
+
if (this.view) {
|
|
879
|
+
const screenSize = this.getScreenSize();
|
|
880
|
+
if (this.view.getState().layout.screenSize !== screenSize) {
|
|
881
|
+
this.view.layout.setScreenSize(screenSize);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
handleKeyboardShortcuts(e) {
|
|
886
|
+
var _a, _b, _c;
|
|
887
|
+
// check if element is visible
|
|
888
|
+
const rect = this.element.getBoundingClientRect();
|
|
889
|
+
if (rect.width + rect.height === 0) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
const { shortcuts } = this.options;
|
|
893
|
+
if (Object.keys(shortcuts).length > 0) {
|
|
894
|
+
const keyboardCommands = getKeyboardCommands(e, shortcuts);
|
|
895
|
+
if (!keyboardCommands.length) {
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
keyboardCommands.forEach((cmd) => {
|
|
899
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
900
|
+
switch (cmd[0]) {
|
|
901
|
+
case 'save': {
|
|
902
|
+
const { allowSaveFile } = this.options.viewer.permissions;
|
|
903
|
+
if (allowSaveFile) {
|
|
904
|
+
e.preventDefault();
|
|
905
|
+
if (this.options.viewer.callbacks.onSaveFileButtonClicked) {
|
|
906
|
+
this.options.viewer.onSaveFileButtonClicked();
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
this.downloadFile();
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
case 'print': {
|
|
915
|
+
const { allowPrinting } = this.options.viewer.permissions;
|
|
916
|
+
if (allowPrinting) {
|
|
917
|
+
e.preventDefault();
|
|
918
|
+
(_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.print();
|
|
919
|
+
}
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
case 'cancelPrint': {
|
|
923
|
+
const { allowPrinting } = this.options.viewer.permissions;
|
|
924
|
+
if (allowPrinting) {
|
|
925
|
+
(_b = this.viewerCanvas) === null || _b === void 0 ? void 0 : _b.deactivateModule('PrintServiceModule');
|
|
926
|
+
}
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
case 'search': {
|
|
930
|
+
const { enableSearch } = this.options.viewer.permissions;
|
|
931
|
+
if (enableSearch) {
|
|
932
|
+
e.preventDefault();
|
|
933
|
+
(_c = this.view) === null || _c === void 0 ? void 0 : _c.search.openSearch();
|
|
934
|
+
}
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
937
|
+
case 'searchNext': {
|
|
938
|
+
const { enableSearch } = this.options.viewer.permissions;
|
|
939
|
+
if (enableSearch) {
|
|
940
|
+
const state = (_d = this.view) === null || _d === void 0 ? void 0 : _d.getState();
|
|
941
|
+
if (state && state.search && state.search.showSearch && state.search.searchString) {
|
|
942
|
+
(_e = this.viewerCanvas) === null || _e === void 0 ? void 0 : _e.nextSearchMatch();
|
|
943
|
+
}
|
|
944
|
+
e.preventDefault();
|
|
945
|
+
}
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
case 'searchPrevious': {
|
|
949
|
+
const { enableSearch } = this.options.viewer.permissions;
|
|
950
|
+
if (enableSearch) {
|
|
951
|
+
const state = (_f = this.view) === null || _f === void 0 ? void 0 : _f.getState();
|
|
952
|
+
if (state && state.search && state.search.showSearch && state.search.searchString) {
|
|
953
|
+
(_g = this.viewerCanvas) === null || _g === void 0 ? void 0 : _g.previousSearchMatch();
|
|
954
|
+
}
|
|
955
|
+
e.preventDefault();
|
|
956
|
+
}
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
case 'closeSearch': {
|
|
960
|
+
const { enableSearch } = this.options.viewer.permissions;
|
|
961
|
+
if (enableSearch) {
|
|
962
|
+
e.preventDefault();
|
|
963
|
+
(_h = this.viewerCanvas) === null || _h === void 0 ? void 0 : _h.endSearch();
|
|
964
|
+
(_j = this.view) === null || _j === void 0 ? void 0 : _j.search.closeSearch();
|
|
965
|
+
}
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
case 'toggleSidePane': {
|
|
969
|
+
const { sidebar } = this.options.viewer;
|
|
970
|
+
if (sidebar.annotationNavigation ||
|
|
971
|
+
sidebar.outlineNavigation ||
|
|
972
|
+
sidebar.annotationNavigation) {
|
|
973
|
+
e.preventDefault();
|
|
974
|
+
(_k = this.view) === null || _k === void 0 ? void 0 : _k.navigationPanel.toggleNavigationPanel();
|
|
975
|
+
}
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
case 'showAnnotations': {
|
|
979
|
+
const { sidebar } = this.options.viewer;
|
|
980
|
+
if (sidebar.annotationNavigation) {
|
|
981
|
+
e.preventDefault();
|
|
982
|
+
(_l = this.view) === null || _l === void 0 ? void 0 : _l.navigationPanel.selectNavigation('annotation');
|
|
983
|
+
}
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
case 'showOutline': {
|
|
987
|
+
const { sidebar } = this.options.viewer;
|
|
988
|
+
if (sidebar.outlineNavigation) {
|
|
989
|
+
e.preventDefault();
|
|
990
|
+
(_m = this.view) === null || _m === void 0 ? void 0 : _m.navigationPanel.selectNavigation('outline');
|
|
991
|
+
}
|
|
992
|
+
break;
|
|
993
|
+
}
|
|
994
|
+
case 'showThumbnails': {
|
|
995
|
+
const { sidebar } = this.options.viewer;
|
|
996
|
+
if (sidebar.thumbnailNavigation) {
|
|
997
|
+
e.preventDefault();
|
|
998
|
+
(_o = this.view) === null || _o === void 0 ? void 0 : _o.navigationPanel.selectNavigation('thumbnail');
|
|
999
|
+
}
|
|
1000
|
+
break;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
else if (e.key === 'Escape') {
|
|
1006
|
+
(_a = this.viewerCanvas) === null || _a === void 0 ? void 0 : _a.deactivateModule('PrintServiceModule');
|
|
1007
|
+
(_b = this.viewerCanvas) === null || _b === void 0 ? void 0 : _b.endSearch();
|
|
1008
|
+
(_c = this.view) === null || _c === void 0 ? void 0 : _c.search.closeSearch();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
showUnconfirmedChangesDialog() {
|
|
1012
|
+
if (this.view && this.viewerCanvas) {
|
|
1013
|
+
const currentState = this.view.getState();
|
|
1014
|
+
const hasChanges = this.viewerCanvas.hasChanges();
|
|
1015
|
+
return (!currentState.unsavedChangesDialogDontSave &&
|
|
1016
|
+
currentState.hasDocument &&
|
|
1017
|
+
hasChanges &&
|
|
1018
|
+
this.options.viewer.general.promptOnUnsavedChange &&
|
|
1019
|
+
this.options.viewer.permissions.allowSaveFile);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
beforeOpen(args) {
|
|
1023
|
+
if (this.view && this.viewerCanvas) {
|
|
1024
|
+
if (this.showUnconfirmedChangesDialog()) {
|
|
1025
|
+
this.view.showConfirmUnsavedChangesDialog(args);
|
|
1026
|
+
return false;
|
|
1027
|
+
}
|
|
1028
|
+
this.view.navigationPanel.clear();
|
|
1029
|
+
this.view.loadDocumentBegin();
|
|
1030
|
+
return true;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
openResolve(fileOpenArgs) {
|
|
1034
|
+
if (this.view && this.viewerCanvas) {
|
|
1035
|
+
this.view.pdfDocument.setFileInfo(fileOpenArgs.pdfFile);
|
|
1036
|
+
this.view.pdfDocument.setHasChanges(false);
|
|
1037
|
+
const pageCount = this.viewerCanvas.getPageCount();
|
|
1038
|
+
this.view.pdfDocument.setPageCount(pageCount);
|
|
1039
|
+
this.handleDocumentOpened();
|
|
1040
|
+
this.view.loadDocumentFulfilled();
|
|
1041
|
+
this.view.api.loadNavigationItems();
|
|
1042
|
+
const inputFile = fileOpenArgs.pdfFile;
|
|
1043
|
+
const eventArg = inputFile.uri
|
|
1044
|
+
? inputFile.uri
|
|
1045
|
+
: new File([], inputFile.sourceTag, { type: 'application/pdf' });
|
|
1046
|
+
this.dispatchEvent('documentLoaded', eventArg);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
openReject(fileOpenArgs, error) {
|
|
1050
|
+
if (this.view) {
|
|
1051
|
+
if (error.message === 'password required') {
|
|
1052
|
+
this.view.loadDocumentPasswordForm(fileOpenArgs);
|
|
1053
|
+
}
|
|
1054
|
+
else {
|
|
1055
|
+
this.view.loadDocumentRejected(error.message);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
handleDocumentOpened() {
|
|
1060
|
+
if (this.view && this.viewerCanvas) {
|
|
1061
|
+
const pageCount = this.viewerCanvas.getPageCount();
|
|
1062
|
+
this.view.navigationPanel.setThumbnailPlaceholders(pageCount);
|
|
1063
|
+
const viewerState = this.view.getState();
|
|
1064
|
+
this.view.navigationPanel.clearAnnotations();
|
|
1065
|
+
if (viewerState.navigationPanel.showNavigation) {
|
|
1066
|
+
if (viewerState.navigationPanel.selectedNavigation === 'thumbnail') {
|
|
1067
|
+
this.loadPageThumbnails();
|
|
1068
|
+
}
|
|
1069
|
+
else if (viewerState.navigationPanel.selectedNavigation === 'outline') {
|
|
1070
|
+
this.loadDocumentOutlines();
|
|
1071
|
+
}
|
|
1072
|
+
else {
|
|
1073
|
+
this.loadAnnotations();
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
loadDocumentOutlines() {
|
|
1079
|
+
if (this.viewerCanvas) {
|
|
1080
|
+
this.viewerCanvas.getDocumentOutline().then((outlines) => {
|
|
1081
|
+
if (this.view) {
|
|
1082
|
+
this.view.navigationPanel.setOutlines(outlines);
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
loadPageThumbnails() {
|
|
1088
|
+
if (this.view && this.viewerCanvas) {
|
|
1089
|
+
const state = this.view.getState();
|
|
1090
|
+
const fromPage = state.pdfDocument.firstVisiblePage - 5;
|
|
1091
|
+
const toPage = state.pdfDocument.lastVisiblePage + 5;
|
|
1092
|
+
this.addPagesToThumbnailsQueue(fromPage, toPage);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
addPagesToThumbnailsQueue(fromPage, toPage) {
|
|
1096
|
+
if (this.view && this.viewerCanvas) {
|
|
1097
|
+
const state = this.view.getState();
|
|
1098
|
+
if (fromPage < 1) {
|
|
1099
|
+
fromPage = 1;
|
|
1100
|
+
}
|
|
1101
|
+
if (toPage < fromPage) {
|
|
1102
|
+
toPage = state.pdfDocument.firstVisiblePage + 5;
|
|
1103
|
+
}
|
|
1104
|
+
if (toPage > state.pdfDocument.pageCount) {
|
|
1105
|
+
toPage = state.pdfDocument.pageCount;
|
|
1106
|
+
}
|
|
1107
|
+
const pagesToLoad = state.navigationPanel.pages
|
|
1108
|
+
.filter((p) => p.pageNumber >= fromPage &&
|
|
1109
|
+
p.pageNumber <= toPage &&
|
|
1110
|
+
p.thumbnail === null &&
|
|
1111
|
+
p.loading === null)
|
|
1112
|
+
.map((p) => p.pageNumber);
|
|
1113
|
+
pagesToLoad.forEach((p) => {
|
|
1114
|
+
var _a;
|
|
1115
|
+
if (this.loadThumbnailsQueue.indexOf(p) < 0) {
|
|
1116
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.navigationPanel.updateThumbnail({
|
|
1117
|
+
pageNumber: p,
|
|
1118
|
+
thumbnail: null,
|
|
1119
|
+
loading: true,
|
|
1120
|
+
});
|
|
1121
|
+
this.loadThumbnailsQueue.push(p);
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
const getPageThumbnail = (pageNumber) => {
|
|
1125
|
+
this.updatePageThumbnail(pageNumber).then(() => {
|
|
1126
|
+
const nextPage = this.loadThumbnailsQueue.shift();
|
|
1127
|
+
if (nextPage) {
|
|
1128
|
+
getPageThumbnail(nextPage);
|
|
1129
|
+
}
|
|
1130
|
+
}).catch(() => { });
|
|
1131
|
+
};
|
|
1132
|
+
const firstPage = this.loadThumbnailsQueue.shift();
|
|
1133
|
+
if (firstPage) {
|
|
1134
|
+
getPageThumbnail(firstPage);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
updatePageThumbnail(pageNumber) {
|
|
1139
|
+
return new Promise((resolve, reject) => {
|
|
1140
|
+
if (this.view && this.viewerCanvas) {
|
|
1141
|
+
this.viewerCanvas
|
|
1142
|
+
.renderPage(pageNumber, 200, 200)
|
|
1143
|
+
.then((thumbnail) => {
|
|
1144
|
+
var _a;
|
|
1145
|
+
const canvasElement = document.createElement('canvas');
|
|
1146
|
+
canvasElement.width = thumbnail.imageData.width;
|
|
1147
|
+
canvasElement.height = thumbnail.imageData.height;
|
|
1148
|
+
const ctx = canvasElement.getContext('2d');
|
|
1149
|
+
ctx && ctx.putImageData(thumbnail.imageData, 0, 0);
|
|
1150
|
+
const imageData = canvasElement.toDataURL('image/png');
|
|
1151
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.navigationPanel.updateThumbnail({
|
|
1152
|
+
pageNumber: thumbnail.page,
|
|
1153
|
+
thumbnail: imageData,
|
|
1154
|
+
loading: false,
|
|
1155
|
+
});
|
|
1156
|
+
resolve();
|
|
1157
|
+
})
|
|
1158
|
+
.catch((error) => reject(error));
|
|
1159
|
+
}
|
|
1160
|
+
else {
|
|
1161
|
+
reject();
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
loadAnnotations() {
|
|
1166
|
+
if (!this.options.viewer.sidebar.annotationNavigation) {
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (this.view) {
|
|
1170
|
+
const state = this.view.getState();
|
|
1171
|
+
if (state.navigationPanel.annotationsLoaded) {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
this.view.navigationPanel.initAnnotations(state.pdfDocument.pageCount);
|
|
1175
|
+
const loadNext = (pages) => {
|
|
1176
|
+
if (this.viewerCanvas) {
|
|
1177
|
+
const pageNumber = pages.shift();
|
|
1178
|
+
if (typeof pageNumber === 'number') {
|
|
1179
|
+
this.viewerCanvas
|
|
1180
|
+
.getAnnotationsFromPage(pageNumber)
|
|
1181
|
+
.then((itemsOnPage) => {
|
|
1182
|
+
var _a, _b;
|
|
1183
|
+
const selectableItems = itemsOnPage.items.filter((item) => { var _a; return (_a = item.behaviors) === null || _a === void 0 ? void 0 : _a.selectable; });
|
|
1184
|
+
if (selectableItems.length) {
|
|
1185
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.navigationPanel.setPageAnnotations({
|
|
1186
|
+
page: itemsOnPage.page,
|
|
1187
|
+
itemCategory: PdfItemCategory.ANNOTATION,
|
|
1188
|
+
items: selectableItems,
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
if (pages.length > 0) {
|
|
1192
|
+
loadNext(pages);
|
|
1193
|
+
}
|
|
1194
|
+
else {
|
|
1195
|
+
(_b = this.view) === null || _b === void 0 ? void 0 : _b.navigationPanel.setAnnotationLoaded();
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
const pageCount = this.getPageCount() || 0;
|
|
1202
|
+
const pageNumbers = [];
|
|
1203
|
+
for (let i = 1; i <= pageCount; i++) {
|
|
1204
|
+
pageNumbers.push(i);
|
|
1205
|
+
}
|
|
1206
|
+
loadNext(pageNumbers);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
handleDocumentClosed() {
|
|
1210
|
+
var _a, _b;
|
|
1211
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.closeDocument();
|
|
1212
|
+
(_b = this.viewerCanvas) === null || _b === void 0 ? void 0 : _b.close();
|
|
1213
|
+
this.handleResize();
|
|
1214
|
+
this.dispatchEvent('documentClosed', undefined);
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
handleAppLoaded(loaded) {
|
|
1218
|
+
if (this.view && this.viewerCanvas) {
|
|
1219
|
+
this.view.initializeAppFulfilled({ licenseFeatures: this.viewerCanvas.licenseFeatures });
|
|
1220
|
+
const canvasModules = this.viewerCanvas.getModules();
|
|
1221
|
+
this.view.setCanvasModules(canvasModules);
|
|
1222
|
+
this.dispatchEvent('appLoaded', loaded);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
handleFirstVisiblePageChanged(page) {
|
|
1226
|
+
if (this.view) {
|
|
1227
|
+
this.visiblePageRange.firstPage = page;
|
|
1228
|
+
this.updateVisiblePageRange();
|
|
1229
|
+
this.view.pdfDocument.setFirstVisiblePage(page);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
handleLastVisiblePageChanged(page) {
|
|
1233
|
+
if (this.view) {
|
|
1234
|
+
this.visiblePageRange.lastPage = page;
|
|
1235
|
+
this.updateVisiblePageRange();
|
|
1236
|
+
this.view.pdfDocument.setLastVisiblePage(page);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
handlePageNumberChanged(page) {
|
|
1240
|
+
if (this.view) {
|
|
1241
|
+
this.view.pdfDocument.setPageNumber(page);
|
|
1242
|
+
const { navigationPanel } = this.view.getState();
|
|
1243
|
+
if (navigationPanel.showNavigation && navigationPanel.selectedNavigation === 'thumbnail') {
|
|
1244
|
+
const elm = this.element.querySelector(`#pwv-thumbnail-navigation-page_${page}`);
|
|
1245
|
+
const container = this.element.querySelector('.pwv-NavigationPanel__Content');
|
|
1246
|
+
if (elm && container) {
|
|
1247
|
+
const containerBoundingRect = container.getBoundingClientRect();
|
|
1248
|
+
const pageBoundingRect = elm.getBoundingClientRect();
|
|
1249
|
+
if (pageBoundingRect.top < containerBoundingRect.top ||
|
|
1250
|
+
pageBoundingRect.bottom > containerBoundingRect.bottom) {
|
|
1251
|
+
elm.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
this.dispatchEvent('pageNumberChanged', page);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
updateVisiblePageRange() {
|
|
1259
|
+
if (this.view) {
|
|
1260
|
+
const state = this.view.getState();
|
|
1261
|
+
if (state.navigationPanel.showNavigation &&
|
|
1262
|
+
state.navigationPanel.selectedNavigation === 'thumbnail') {
|
|
1263
|
+
if (this.loadPageThumbnailsTimer) {
|
|
1264
|
+
window.clearTimeout(this.loadPageThumbnailsTimer);
|
|
1265
|
+
}
|
|
1266
|
+
this.loadPageThumbnailsTimer = window.setTimeout(() => {
|
|
1267
|
+
this.loadPageThumbnailsTimer = null;
|
|
1268
|
+
this.loadPageThumbnails();
|
|
1269
|
+
}, 100);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
handleZoomChanged(zoom) {
|
|
1274
|
+
if (this.view) {
|
|
1275
|
+
this.view.pdfDocument.setZoom(zoom * 100);
|
|
1276
|
+
this.dispatchEvent('zoomChanged', zoom);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
handleFitModeChanged(fitMode) {
|
|
1280
|
+
if (this.view) {
|
|
1281
|
+
this.view.pdfDocument.setFitMode(fitMode);
|
|
1282
|
+
}
|
|
1283
|
+
this.dispatchEvent('fitModeChanged', fitMode);
|
|
1284
|
+
}
|
|
1285
|
+
handlePageLayoutModeChanged(layoutMode) {
|
|
1286
|
+
if (this.view) {
|
|
1287
|
+
this.view.pdfDocument.setPageLayoutMode(layoutMode);
|
|
1288
|
+
}
|
|
1289
|
+
this.dispatchEvent('pageLayoutModeChanged', layoutMode);
|
|
1290
|
+
}
|
|
1291
|
+
handleRotationChanged(rotation) {
|
|
1292
|
+
this.dispatchEvent('rotationChanged', rotation);
|
|
1293
|
+
}
|
|
1294
|
+
handleBusyStateChanged(state) {
|
|
1295
|
+
this.dispatchEvent('busyState', state);
|
|
1296
|
+
}
|
|
1297
|
+
handleAnnotationSelected(item) {
|
|
1298
|
+
if (this.view) {
|
|
1299
|
+
const annotation = item;
|
|
1300
|
+
this.view.navigationPanel.selectAnnotation(annotation);
|
|
1301
|
+
const { navigationPanel } = this.view.getState();
|
|
1302
|
+
if (navigationPanel.showNavigation && navigationPanel.selectedNavigation === 'annotation') {
|
|
1303
|
+
const elm = this.element.querySelector(`#pwv-annotation-navigation-item-${annotation.id}`);
|
|
1304
|
+
if (elm) {
|
|
1305
|
+
elm.scrollIntoView({ behavior: 'smooth' });
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
handleAnnotationDeselected(item) {
|
|
1311
|
+
if (this.view) {
|
|
1312
|
+
this.view.navigationPanel.deselectAnnotation();
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
handleAnnotationCreated(item) {
|
|
1316
|
+
if (this.view) {
|
|
1317
|
+
const annotation = item;
|
|
1318
|
+
this.view.navigationPanel.updateAnnotation(annotation);
|
|
1319
|
+
const { navigationPanel } = this.view.getState();
|
|
1320
|
+
if (navigationPanel.showNavigation && navigationPanel.selectedNavigation === 'annotation') {
|
|
1321
|
+
window.setTimeout(() => {
|
|
1322
|
+
const elm = this.element.querySelector(`#pwv-annotation-navigation-item-${annotation.id}`);
|
|
1323
|
+
if (elm) {
|
|
1324
|
+
elm.scrollIntoView({ behavior: 'smooth' });
|
|
1325
|
+
}
|
|
1326
|
+
}, 10);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
handleAnnotationUpdated(item) {
|
|
1331
|
+
if (this.view) {
|
|
1332
|
+
const annotation = item;
|
|
1333
|
+
this.view.navigationPanel.updateAnnotation(annotation);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
handleAnnotationDeleted(deletedItem) {
|
|
1337
|
+
if (this.view) {
|
|
1338
|
+
this.view.navigationPanel.deleteAnnotation(deletedItem);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
handlePageChanged(pageNumber) {
|
|
1342
|
+
// the list is 0 index based. E.g. page 1 is at index 0
|
|
1343
|
+
if (this.view) {
|
|
1344
|
+
const pageNavigationItem = this.view.getState().navigationPanel.pages[pageNumber - 1];
|
|
1345
|
+
if (pageNavigationItem && pageNavigationItem.thumbnail !== null) {
|
|
1346
|
+
this.updatePageThumbnail(pageNumber);
|
|
1347
|
+
}
|
|
1348
|
+
this.dispatchEvent('documentChanged', undefined);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
handleTextSelected(text) {
|
|
1352
|
+
this.dispatchEvent('textSelected', text);
|
|
1353
|
+
}
|
|
1354
|
+
verifyOptions(clientOptions, defaultOptions) {
|
|
1355
|
+
// Verify annotation Color options
|
|
1356
|
+
if (clientOptions.annotation && clientOptions.annotation.colors) {
|
|
1357
|
+
Object.keys(OptionsToVerify).forEach((k) => {
|
|
1358
|
+
if (clientOptions.annotation && clientOptions.annotation.colors[k]) {
|
|
1359
|
+
if (!this.isContainedInArray(clientOptions.annotation.colors[k], defaultOptions.annotation.colors[OptionsToVerify[k]])) {
|
|
1360
|
+
throw new Error(`Invalid ${k}: ${defaultOptions.annotation.colors[k]} has not been found in ${OptionsToVerify[k]}.\n` +
|
|
1361
|
+
`Valid values are: ${defaultOptions.annotation.colors[OptionsToVerify[k]]}`);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
Object.keys(ColorPaletteMap).forEach((k) => {
|
|
1366
|
+
if (clientOptions.annotation &&
|
|
1367
|
+
clientOptions.annotation.colors[k] &&
|
|
1368
|
+
!clientOptions.annotation.colors[ColorPaletteMap[k]]) {
|
|
1369
|
+
throw new Error(`Cannot set ${k} without setting ${ColorPaletteMap[k]}. Preset ${ColorPaletteMap[k]} might not be in ${k}`);
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
isContainedInArray(item, list) {
|
|
1375
|
+
if (!list.find((el) => el === item)) {
|
|
1376
|
+
return false;
|
|
1377
|
+
}
|
|
1378
|
+
return true;
|
|
1379
|
+
}
|
|
1380
|
+
handleError(error) {
|
|
1381
|
+
if (this.view) {
|
|
1382
|
+
this.view.setError(error.message);
|
|
1383
|
+
}
|
|
1384
|
+
this.dispatchEvent('error', error);
|
|
1385
|
+
}
|
|
1386
|
+
}
|