@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,1226 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { createStore } from './state/store';
|
|
11
|
+
import { PdfViewerApi, PdfFitMode, PdfItemCategory, FileType, DocumentChange, } from '../pdf-viewer-api';
|
|
12
|
+
import { translationManager } from '../common/TranslationManager';
|
|
13
|
+
import { tooltipManager } from '../common/TooltipManager';
|
|
14
|
+
import { CanvasEvents } from './CanvasEvents';
|
|
15
|
+
import { StampAnnotationModule } from '../modules/stamp-annotation/StampAnnotationModule';
|
|
16
|
+
import { PdfDocumentLayer } from './view-layers/PdfDocumentLayer';
|
|
17
|
+
import { ScrollLayer } from './view-layers/ScrollLayer';
|
|
18
|
+
import { BusyStateLayer } from './view-layers/BusyStateLayer';
|
|
19
|
+
import { AnnotationSelectionLayer } from './view-layers/AnnotationSelectionLayer';
|
|
20
|
+
import { TextSelectionLayer } from './view-layers/TextSelectionLayer';
|
|
21
|
+
import { ViewerMode, CursorStyle, copyTextToClipboard } from './state/viewer';
|
|
22
|
+
import { imageDataUrlToUint8Array } from '../common/Tools';
|
|
23
|
+
import { PdfViewing } from '../pdf-viewing/PdfViewing';
|
|
24
|
+
import { getKeyboardCommands } from '../common/utils';
|
|
25
|
+
import { PopupModule } from '../modules';
|
|
26
|
+
export class PdfViewerCanvas {
|
|
27
|
+
get licenseFeatures() {
|
|
28
|
+
const licenseFeatures = this.pdfViewerApi.getSupportedFeatures();
|
|
29
|
+
return {
|
|
30
|
+
annotate: !this.options.viewer.general.viewOnly &&
|
|
31
|
+
PdfViewing.LicenseFeature.Annotate ===
|
|
32
|
+
(licenseFeatures & PdfViewing.LicenseFeature.Annotate),
|
|
33
|
+
fillFormFields: !this.options.viewer.general.viewOnly &&
|
|
34
|
+
PdfViewing.LicenseFeature.FillFormFields ===
|
|
35
|
+
(licenseFeatures & PdfViewing.LicenseFeature.FillFormFields),
|
|
36
|
+
pageRotation: !this.options.viewer.general.viewOnly &&
|
|
37
|
+
PdfViewing.LicenseFeature.PageRotation ===
|
|
38
|
+
(licenseFeatures & PdfViewing.LicenseFeature.PageRotation),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
constructor(containerElement, license, options) {
|
|
42
|
+
var _a;
|
|
43
|
+
this.eventListeners = new Map();
|
|
44
|
+
this.documentLoaded = false;
|
|
45
|
+
this.renderLoopRunning = false;
|
|
46
|
+
if (!containerElement) {
|
|
47
|
+
throw { error: 'PdfViewerCanvas container element is null' };
|
|
48
|
+
}
|
|
49
|
+
this.options = options;
|
|
50
|
+
this.annotTimer = 0;
|
|
51
|
+
// bind events
|
|
52
|
+
this.onResize = this.onResize.bind(this);
|
|
53
|
+
this.startRenderLoop = this.startRenderLoop.bind(this);
|
|
54
|
+
this.updateViewLayerContext = this.updateViewLayerContext.bind(this);
|
|
55
|
+
this.onKeyboardShortcuts = this.onKeyboardShortcuts.bind(this);
|
|
56
|
+
this.dispatchEvent = this.dispatchEvent.bind(this);
|
|
57
|
+
this.onCanvasPointerDown = this.onCanvasPointerDown.bind(this);
|
|
58
|
+
this.onCanvasPointerMove = this.onCanvasPointerMove.bind(this);
|
|
59
|
+
this.onCanvasPointerUp = this.onCanvasPointerUp.bind(this);
|
|
60
|
+
this.onCanvasPointerClick = this.onCanvasPointerClick.bind(this);
|
|
61
|
+
this.onCanvasPointerDblClick = this.onCanvasPointerDblClick.bind(this);
|
|
62
|
+
this.onCanvasPointerLongPress = this.onCanvasPointerLongPress.bind(this);
|
|
63
|
+
this.onCanvasPointerStartDrag = this.onCanvasPointerStartDrag.bind(this);
|
|
64
|
+
this.onCanvasPointerEndDrag = this.onCanvasPointerEndDrag.bind(this);
|
|
65
|
+
this.onCanvasPointerPinch = this.onCanvasPointerPinch.bind(this);
|
|
66
|
+
this.onMouseWheel = this.onMouseWheel.bind(this);
|
|
67
|
+
this.onDocumentOpened = this.onDocumentOpened.bind(this);
|
|
68
|
+
this.onDocumentClosed = this.onDocumentClosed.bind(this);
|
|
69
|
+
this.onCanvasInvalidated = this.onCanvasInvalidated.bind(this);
|
|
70
|
+
this.onFirstVisiblePageChanged = this.onFirstVisiblePageChanged.bind(this);
|
|
71
|
+
this.onLastVisiblePageChanged = this.onLastVisiblePageChanged.bind(this);
|
|
72
|
+
this.onPageNumberChanged = this.onPageNumberChanged.bind(this);
|
|
73
|
+
this.onZoomChanged = this.onZoomChanged.bind(this);
|
|
74
|
+
this.onFitModeChanged = this.onFitModeChanged.bind(this);
|
|
75
|
+
this.onPageLayoutModeChanged = this.onPageLayoutModeChanged.bind(this);
|
|
76
|
+
this.onBusyStateChanged = this.onBusyStateChanged.bind(this);
|
|
77
|
+
this.onRotationChanged = this.onRotationChanged.bind(this);
|
|
78
|
+
this.onItemCreated = this.onItemCreated.bind(this);
|
|
79
|
+
this.onItemUpdated = this.onItemUpdated.bind(this);
|
|
80
|
+
this.onItemDeleted = this.onItemDeleted.bind(this);
|
|
81
|
+
this.onPageChanged = this.onPageChanged.bind(this);
|
|
82
|
+
this.onTextSelected = this.onTextSelected.bind(this);
|
|
83
|
+
this.onHtmlDocumentSelectionChanged = this.onHtmlDocumentSelectionChanged.bind(this);
|
|
84
|
+
this.onApiError = this.onApiError.bind(this);
|
|
85
|
+
this.beforeUnloadCallback = this.beforeUnloadCallback.bind(this);
|
|
86
|
+
this.getAnnotations = this.getAnnotations.bind(this);
|
|
87
|
+
this.openRoutine = this.openRoutine.bind(this);
|
|
88
|
+
this.print = this.print.bind(this);
|
|
89
|
+
this.close = this.close.bind(this);
|
|
90
|
+
this.searchIterator = null;
|
|
91
|
+
// create store
|
|
92
|
+
this.store = createStore();
|
|
93
|
+
// create api
|
|
94
|
+
const pdfViewerApiOptions = {
|
|
95
|
+
onlyAuthorCanEdit: (_a = options.annotation.onlyAuthorCanEdit) !== null && _a !== void 0 ? _a : false,
|
|
96
|
+
viewOnly: options.viewer.general.viewOnly,
|
|
97
|
+
user: options.viewer.general.user,
|
|
98
|
+
allowPopups: options.modules.includes(PopupModule),
|
|
99
|
+
annotationPermissionCallback: options.annotation.annotationPermissionCallback,
|
|
100
|
+
};
|
|
101
|
+
this.pdfViewerApi = new PdfViewerApi(pdfViewerApiOptions);
|
|
102
|
+
const licenseIsValid = this.pdfViewerApi.setLicenseKey(license);
|
|
103
|
+
if (!licenseIsValid) {
|
|
104
|
+
throw new Error('Invalid License');
|
|
105
|
+
}
|
|
106
|
+
// create elements
|
|
107
|
+
this.element = containerElement;
|
|
108
|
+
this.element.classList.add('pwv-ViewerCanvas');
|
|
109
|
+
const viewerContainer = document.createElement('div');
|
|
110
|
+
viewerContainer.classList.add('pwv-canvas-container');
|
|
111
|
+
this.element.appendChild(viewerContainer);
|
|
112
|
+
this.toolbarElement = document.createElement('div');
|
|
113
|
+
if (this.licenseFeatures.annotate) {
|
|
114
|
+
this.toolbarElement.classList.add('pwv-canvas-toolbar');
|
|
115
|
+
viewerContainer.appendChild(this.toolbarElement);
|
|
116
|
+
}
|
|
117
|
+
const canvasLayers = document.createElement('div');
|
|
118
|
+
canvasLayers.classList.add('pwv-canvas-layers');
|
|
119
|
+
viewerContainer.appendChild(canvasLayers);
|
|
120
|
+
this.viewLayersElement = document.createElement('div');
|
|
121
|
+
canvasLayers.appendChild(this.viewLayersElement);
|
|
122
|
+
viewerContainer.appendChild(canvasLayers);
|
|
123
|
+
this.viewLayers = [];
|
|
124
|
+
this.modules = [];
|
|
125
|
+
// events
|
|
126
|
+
this.resizeObserver = new ResizeObserver(this.onResize);
|
|
127
|
+
this.resizeObserver.observe(canvasLayers);
|
|
128
|
+
this.pdfViewerApi.addEventListener('firstVisiblePage', this.onFirstVisiblePageChanged);
|
|
129
|
+
this.pdfViewerApi.addEventListener('lastVisiblePage', this.onLastVisiblePageChanged);
|
|
130
|
+
this.pdfViewerApi.addEventListener('pageNumber', this.onPageNumberChanged);
|
|
131
|
+
this.pdfViewerApi.addEventListener('zoom', this.onZoomChanged);
|
|
132
|
+
this.pdfViewerApi.addEventListener('fitMode', this.onFitModeChanged);
|
|
133
|
+
this.pdfViewerApi.addEventListener('pageLayoutMode', this.onPageLayoutModeChanged);
|
|
134
|
+
this.pdfViewerApi.addEventListener('busyState', this.onBusyStateChanged);
|
|
135
|
+
this.pdfViewerApi.addEventListener('canvasInvalidated', this.onCanvasInvalidated);
|
|
136
|
+
this.pdfViewerApi.addEventListener('itemCreated', this.onItemCreated);
|
|
137
|
+
this.pdfViewerApi.addEventListener('itemUpdated', this.onItemUpdated);
|
|
138
|
+
this.pdfViewerApi.addEventListener('itemDeleted', this.onItemDeleted);
|
|
139
|
+
this.pdfViewerApi.addEventListener('pageChanged', this.onPageChanged);
|
|
140
|
+
this.pdfViewerApi.addEventListener('rotation', this.onRotationChanged);
|
|
141
|
+
this.pdfViewerApi.addEventListener('error', this.onApiError);
|
|
142
|
+
if (this.options.viewer.general.promptOnUnsavedChange) {
|
|
143
|
+
window.addEventListener('beforeunload', this.beforeUnloadCallback);
|
|
144
|
+
}
|
|
145
|
+
document.addEventListener('selectionchange', this.onHtmlDocumentSelectionChanged);
|
|
146
|
+
this.canvasEvents = new CanvasEvents(canvasLayers);
|
|
147
|
+
this.canvasEvents.suspend();
|
|
148
|
+
this.canvasEvents.addEventListener('pointerdown', this.onCanvasPointerDown);
|
|
149
|
+
this.canvasEvents.addEventListener('pointermove', this.onCanvasPointerMove);
|
|
150
|
+
this.canvasEvents.addEventListener('pointerup', this.onCanvasPointerUp);
|
|
151
|
+
this.canvasEvents.addEventListener('pointerclick', this.onCanvasPointerClick);
|
|
152
|
+
this.canvasEvents.addEventListener('pointerdblclick', this.onCanvasPointerDblClick);
|
|
153
|
+
this.canvasEvents.addEventListener('pointerlongpress', this.onCanvasPointerLongPress);
|
|
154
|
+
this.canvasEvents.addEventListener('pointerstartdrag', this.onCanvasPointerStartDrag);
|
|
155
|
+
this.canvasEvents.addEventListener('pointerenddrag', this.onCanvasPointerEndDrag);
|
|
156
|
+
this.canvasEvents.addEventListener('pinch', this.onCanvasPointerPinch);
|
|
157
|
+
this.viewLayersElement.addEventListener('wheel', this.onMouseWheel, {
|
|
158
|
+
passive: false,
|
|
159
|
+
});
|
|
160
|
+
document.addEventListener('keydown', this.onKeyboardShortcuts, {
|
|
161
|
+
passive: false,
|
|
162
|
+
});
|
|
163
|
+
translationManager.loadTranslations(this.options.viewer.general.language || 'en');
|
|
164
|
+
tooltipManager.setType(this.options.viewer.general.tooltips || 'title');
|
|
165
|
+
if (this.options.modules) {
|
|
166
|
+
// load pdf for stamps
|
|
167
|
+
if (this.licenseFeatures.annotate &&
|
|
168
|
+
this.options.modules.find((m) => m === StampAnnotationModule) &&
|
|
169
|
+
this.options.annotation.options.pdfStampFiles) {
|
|
170
|
+
this.registerPdfStamps(this.options.annotation.options.pdfStampFiles);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Push the dispatching of the appLoaded event to the macro task queue
|
|
174
|
+
// otherwise any function added to the appLoaded event won't be notified
|
|
175
|
+
// since the event has already been dispatched
|
|
176
|
+
requestAnimationFrame(() => {
|
|
177
|
+
this.dispatchEvent('appLoaded', true);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
open(pdfFile, fdfFiles, password, viewOptions, renderOptions) {
|
|
181
|
+
const _viewOptions = viewOptions ? viewOptions : {};
|
|
182
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
183
|
+
const viewportSize = {
|
|
184
|
+
width: containerRect.width,
|
|
185
|
+
height: containerRect.height,
|
|
186
|
+
};
|
|
187
|
+
return this.openRoutine(this.pdfViewerApi.open, pdfFile, fdfFiles, password, _viewOptions, renderOptions, viewportSize);
|
|
188
|
+
}
|
|
189
|
+
save(saveOptions) {
|
|
190
|
+
const promises = new Array();
|
|
191
|
+
for (let i = 0; i < this.modules.length; i++) {
|
|
192
|
+
promises.push(this.modules[i].onSave());
|
|
193
|
+
}
|
|
194
|
+
const savePromise = new Promise((resolve, reject) => {
|
|
195
|
+
Promise.all(promises).then(() => {
|
|
196
|
+
return this.pdfViewerApi
|
|
197
|
+
.save(saveOptions)
|
|
198
|
+
.then((buffer) => {
|
|
199
|
+
resolve(buffer);
|
|
200
|
+
})
|
|
201
|
+
.catch((err) => {
|
|
202
|
+
reject(err);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
return savePromise;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated Deprecated in Version 3.10. Use Open method instead.
|
|
210
|
+
*/
|
|
211
|
+
openFDF(pdfBuffer, fdfBuffer, password) {
|
|
212
|
+
return this.open({ data: pdfBuffer }, [{ data: fdfBuffer }], password);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* @deprecated Deprecated in Version 3.10. Use Open method instead.
|
|
216
|
+
*/
|
|
217
|
+
openUri(pdfUri, password, pdfAuthorization) {
|
|
218
|
+
return this.open({ uri: pdfUri }, [], password);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated Deprecated in Version 3.10. Use Open method instead.
|
|
222
|
+
*/
|
|
223
|
+
openFDFUri(pdfUri, fdfUri, password, pdfAuthorization, fdfAuthorization) {
|
|
224
|
+
return this.open({ uri: pdfUri }, [{ uri: pdfUri }], password);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @deprecated Deprecated in Version 3.10. Use Open method instead.
|
|
228
|
+
*/
|
|
229
|
+
openBlob(blob, password) {
|
|
230
|
+
return this.open({ data: blob }, [], password);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* @deprecated Deprecated in Version 3.10. Use Open method instead.
|
|
234
|
+
*/
|
|
235
|
+
openFDFBlob(pdfBlob, fdfBlob, password) {
|
|
236
|
+
return this.open({ data: pdfBlob }, [{ data: fdfBlob }], password);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Deprecated in Version 3.10. Use save method instead.
|
|
240
|
+
*/
|
|
241
|
+
saveFile(asFdf) {
|
|
242
|
+
return new Promise((resolve, reject) => {
|
|
243
|
+
const saveOptions = {};
|
|
244
|
+
if (asFdf) {
|
|
245
|
+
saveOptions.fileType = FileType.Fdf;
|
|
246
|
+
}
|
|
247
|
+
this.save(saveOptions).then((blob) => {
|
|
248
|
+
blob.arrayBuffer().then((arrayBuffer) => {
|
|
249
|
+
resolve(new Uint8Array(arrayBuffer));
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
close() {
|
|
255
|
+
this.unRegisterModules();
|
|
256
|
+
this.onDocumentClosed();
|
|
257
|
+
if (this.searchIterator) {
|
|
258
|
+
this.searchIterator.close();
|
|
259
|
+
this.searchIterator = null;
|
|
260
|
+
}
|
|
261
|
+
return this.pdfViewerApi.close();
|
|
262
|
+
}
|
|
263
|
+
destroy() {
|
|
264
|
+
this.stopRenderLoop();
|
|
265
|
+
if (this.searchIterator) {
|
|
266
|
+
this.searchIterator.close();
|
|
267
|
+
}
|
|
268
|
+
this.resizeObserver.disconnect();
|
|
269
|
+
if (this.annotTimer) {
|
|
270
|
+
window.clearTimeout(this.annotTimer);
|
|
271
|
+
}
|
|
272
|
+
// remove listeners
|
|
273
|
+
this.eventListeners.clear();
|
|
274
|
+
document.removeEventListener('keydown', this.onKeyboardShortcuts);
|
|
275
|
+
window.removeEventListener('beforeunload', this.beforeUnloadCallback);
|
|
276
|
+
this.pdfViewerApi.removeEventListener('firstVisiblePage', this.onFirstVisiblePageChanged);
|
|
277
|
+
this.pdfViewerApi.removeEventListener('lastVisiblePage', this.onLastVisiblePageChanged);
|
|
278
|
+
this.pdfViewerApi.removeEventListener('pageNumber', this.onPageNumberChanged);
|
|
279
|
+
this.pdfViewerApi.removeEventListener('zoom', this.onZoomChanged);
|
|
280
|
+
this.pdfViewerApi.removeEventListener('fitMode', this.onFitModeChanged);
|
|
281
|
+
this.pdfViewerApi.removeEventListener('pageLayoutMode', this.onPageLayoutModeChanged);
|
|
282
|
+
this.pdfViewerApi.removeEventListener('busyState', this.onBusyStateChanged);
|
|
283
|
+
this.pdfViewerApi.removeEventListener('canvasInvalidated', this.onCanvasInvalidated);
|
|
284
|
+
this.pdfViewerApi.removeEventListener('itemCreated', this.onItemCreated);
|
|
285
|
+
this.pdfViewerApi.removeEventListener('itemUpdated', this.onItemUpdated);
|
|
286
|
+
this.pdfViewerApi.removeEventListener('itemDeleted', this.onItemDeleted);
|
|
287
|
+
this.pdfViewerApi.removeEventListener('pageChanged', this.onPageChanged);
|
|
288
|
+
this.pdfViewerApi.removeEventListener('rotation', this.onRotationChanged);
|
|
289
|
+
this.pdfViewerApi.removeEventListener('error', this.onApiError);
|
|
290
|
+
this.canvasEvents.suspend();
|
|
291
|
+
this.canvasEvents.removeEventListener('pointerdown', this.onCanvasPointerDown);
|
|
292
|
+
this.canvasEvents.removeEventListener('pointermove', this.onCanvasPointerMove);
|
|
293
|
+
this.canvasEvents.removeEventListener('pointerup', this.onCanvasPointerUp);
|
|
294
|
+
this.canvasEvents.removeEventListener('pointerclick', this.onCanvasPointerClick);
|
|
295
|
+
this.canvasEvents.removeEventListener('pointerdblclick', this.onCanvasPointerDblClick);
|
|
296
|
+
this.canvasEvents.removeEventListener('pointerlongpress', this.onCanvasPointerLongPress);
|
|
297
|
+
this.canvasEvents.removeEventListener('pointerstartdrag', this.onCanvasPointerStartDrag);
|
|
298
|
+
this.canvasEvents.removeEventListener('pointerenddrag', this.onCanvasPointerEndDrag);
|
|
299
|
+
this.canvasEvents.removeEventListener('pinch', this.onCanvasPointerPinch);
|
|
300
|
+
this.viewLayersElement.removeEventListener('wheel', this.onMouseWheel);
|
|
301
|
+
this.pdfViewerApi.destroy();
|
|
302
|
+
this.viewLayers = [];
|
|
303
|
+
this.modules = [];
|
|
304
|
+
// remove all child elements
|
|
305
|
+
while (this.element.firstChild) {
|
|
306
|
+
this.element.removeChild(this.element.firstChild);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
hasChanges() {
|
|
310
|
+
return this.pdfViewerApi.hasChanges();
|
|
311
|
+
}
|
|
312
|
+
getProductVersion() {
|
|
313
|
+
return PdfViewing.Sdk.version;
|
|
314
|
+
}
|
|
315
|
+
getZoom() {
|
|
316
|
+
return this.pdfViewerApi.getZoom();
|
|
317
|
+
}
|
|
318
|
+
setZoom(zoom, location) {
|
|
319
|
+
this.pdfViewerApi.setZoom(zoom, location);
|
|
320
|
+
}
|
|
321
|
+
zoomIn(location) {
|
|
322
|
+
const zoom = this.pdfViewerApi.getZoom();
|
|
323
|
+
this.pdfViewerApi.setZoom(this.getNextZoomInLevel(zoom), location);
|
|
324
|
+
}
|
|
325
|
+
zoomOut(location) {
|
|
326
|
+
const zoom = this.pdfViewerApi.getZoom();
|
|
327
|
+
this.pdfViewerApi.setZoom(this.getNextZoomOutLevel(zoom), location);
|
|
328
|
+
}
|
|
329
|
+
getPageCount() {
|
|
330
|
+
return this.pdfViewerApi.getPageCount();
|
|
331
|
+
}
|
|
332
|
+
getPageNumber() {
|
|
333
|
+
return this.pdfViewerApi.getPageNumber();
|
|
334
|
+
}
|
|
335
|
+
rotatePage(pageNumber, direction) {
|
|
336
|
+
const { textSelection, selectedAnnotationId, selectedModuleName } = this.store.getState().viewer;
|
|
337
|
+
if (textSelection) {
|
|
338
|
+
const textSelectionLayer = this.viewLayers.find((v) => v instanceof TextSelectionLayer);
|
|
339
|
+
if (textSelectionLayer) {
|
|
340
|
+
textSelectionLayer.clearSelection();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (selectedAnnotationId) {
|
|
344
|
+
this.store.viewer.deselectAnnotation();
|
|
345
|
+
}
|
|
346
|
+
if (selectedModuleName) {
|
|
347
|
+
this.store.viewer.endModule(selectedModuleName);
|
|
348
|
+
}
|
|
349
|
+
return this.pdfViewerApi.rotatePage(pageNumber, direction);
|
|
350
|
+
}
|
|
351
|
+
setPageNumber(page) {
|
|
352
|
+
if (page < 1) {
|
|
353
|
+
page = 1;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
const pageCount = this.pdfViewerApi.getPageCount();
|
|
357
|
+
if (page > pageCount) {
|
|
358
|
+
page = pageCount;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
this.pdfViewerApi.setPageNumber(page);
|
|
362
|
+
}
|
|
363
|
+
scrollDown(distance = 100) {
|
|
364
|
+
if (distance === 0) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const pos = this.pdfViewerApi.getScrollPosition();
|
|
368
|
+
pos.y += distance * window.devicePixelRatio;
|
|
369
|
+
this.pdfViewerApi.setScrollPosition(pos);
|
|
370
|
+
}
|
|
371
|
+
scrollUp(distance = 100) {
|
|
372
|
+
if (distance === 0) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const pos = this.pdfViewerApi.getScrollPosition();
|
|
376
|
+
pos.y -= distance * window.devicePixelRatio;
|
|
377
|
+
this.pdfViewerApi.setScrollPosition(pos);
|
|
378
|
+
}
|
|
379
|
+
scrollLeft(distance = 100) {
|
|
380
|
+
if (distance === 0) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const pos = this.pdfViewerApi.getScrollPosition();
|
|
384
|
+
pos.x -= distance * window.devicePixelRatio;
|
|
385
|
+
this.pdfViewerApi.setScrollPosition(pos);
|
|
386
|
+
}
|
|
387
|
+
scrollRight(distance = 100) {
|
|
388
|
+
if (distance === 0) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const pos = this.pdfViewerApi.getScrollPosition();
|
|
392
|
+
pos.x += distance * window.devicePixelRatio;
|
|
393
|
+
this.pdfViewerApi.setScrollPosition(pos);
|
|
394
|
+
}
|
|
395
|
+
scrollMove(distanceVertical = 0, distanceHorizontal = 0) {
|
|
396
|
+
if (distanceVertical === 0 && distanceHorizontal === 0) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const pos = this.pdfViewerApi.getScrollPosition();
|
|
400
|
+
pos.y += distanceVertical * window.devicePixelRatio;
|
|
401
|
+
pos.x += distanceHorizontal * window.devicePixelRatio;
|
|
402
|
+
this.pdfViewerApi.setScrollPosition(pos);
|
|
403
|
+
}
|
|
404
|
+
nextPage() {
|
|
405
|
+
const page = this.pdfViewerApi.getPageNumber();
|
|
406
|
+
const pageCount = this.pdfViewerApi.getPageCount();
|
|
407
|
+
if (page < pageCount) {
|
|
408
|
+
this.pdfViewerApi.setPageNumber(page + 1);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
previousPage() {
|
|
412
|
+
const page = this.pdfViewerApi.getPageNumber();
|
|
413
|
+
if (page > 1) {
|
|
414
|
+
this.pdfViewerApi.setPageNumber(page - 1);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
getFitMode() {
|
|
418
|
+
return this.pdfViewerApi.getFitMode();
|
|
419
|
+
}
|
|
420
|
+
setFitMode(fitMode) {
|
|
421
|
+
this.pdfViewerApi.setFitMode(fitMode);
|
|
422
|
+
}
|
|
423
|
+
getPageLayoutMode() {
|
|
424
|
+
return this.pdfViewerApi.getPageLayoutMode();
|
|
425
|
+
}
|
|
426
|
+
setPageLayoutMode(pageLayoutMode) {
|
|
427
|
+
this.pdfViewerApi.setPageLayoutMode(pageLayoutMode);
|
|
428
|
+
}
|
|
429
|
+
getRotation() {
|
|
430
|
+
return this.pdfViewerApi.getRotation();
|
|
431
|
+
}
|
|
432
|
+
setRotation(rotation) {
|
|
433
|
+
this.pdfViewerApi.setRotation(rotation);
|
|
434
|
+
}
|
|
435
|
+
renderPage(pageNumber, width, height) {
|
|
436
|
+
return this.pdfViewerApi.renderPage(pageNumber, width, height);
|
|
437
|
+
}
|
|
438
|
+
getDocumentOutline() {
|
|
439
|
+
return this.getOutlines(null);
|
|
440
|
+
}
|
|
441
|
+
goTo(pdfDestination) {
|
|
442
|
+
this.pdfViewerApi.goTo(pdfDestination);
|
|
443
|
+
}
|
|
444
|
+
updateCanvasSearchState(state) {
|
|
445
|
+
this.store.search.start({
|
|
446
|
+
caseSensitive: state.caseSensitive,
|
|
447
|
+
searchString: state.searchString,
|
|
448
|
+
reverse: false,
|
|
449
|
+
useRegex: state.useRegex,
|
|
450
|
+
wrapSearch: state.wrapSearch,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
doSearch() {
|
|
454
|
+
const s = this.store.getState().search;
|
|
455
|
+
if (this.searchIterator &&
|
|
456
|
+
this.searchIterator.match instanceof PdfViewing.Pdf.Content.TextSelection) {
|
|
457
|
+
const list = this.searchIterator.match.textArea;
|
|
458
|
+
let page = 1;
|
|
459
|
+
const quadrilateralList = [];
|
|
460
|
+
for (let i = 0; i < list.size; i++) {
|
|
461
|
+
const quad = list.get(i);
|
|
462
|
+
if (quad.pageNumber > page) {
|
|
463
|
+
page = quad.pageNumber;
|
|
464
|
+
}
|
|
465
|
+
quadrilateralList.push(quad);
|
|
466
|
+
}
|
|
467
|
+
this.store.search.updateMatch({
|
|
468
|
+
match: quadrilateralList,
|
|
469
|
+
page,
|
|
470
|
+
});
|
|
471
|
+
const q = list.get(0);
|
|
472
|
+
const { bottomLeft, bottomRight, topRight, topLeft, pageNumber } = q;
|
|
473
|
+
const x = Math.min(bottomLeft.x, bottomRight.x, topRight.x, topLeft.x);
|
|
474
|
+
const y = Math.min(bottomLeft.y, bottomRight.y, topRight.y, topLeft.y);
|
|
475
|
+
const padding = 10;
|
|
476
|
+
const rect = {
|
|
477
|
+
pdfX: x - padding,
|
|
478
|
+
pdfY: y - padding,
|
|
479
|
+
pdfW: Math.max(bottomLeft.x, bottomRight.x, topRight.x, topLeft.x) - x + 2 * padding,
|
|
480
|
+
pdfH: Math.max(bottomLeft.y, bottomRight.y, topRight.y, topLeft.y) - y + 2 * padding,
|
|
481
|
+
page: pageNumber,
|
|
482
|
+
};
|
|
483
|
+
this.pdfViewerApi.goToRectangle(rect);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
startSearch(searchString, startPage, caseSensitive, wrapSearch, useRegex) {
|
|
487
|
+
if (this.searchIterator) {
|
|
488
|
+
this.endSearch();
|
|
489
|
+
}
|
|
490
|
+
this.searchIterator = this.pdfViewerApi.getSearchIterator(searchString, startPage, caseSensitive, wrapSearch, useRegex);
|
|
491
|
+
if (!this.searchIterator) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.searchIterator.getNext().then((hasResult) => {
|
|
495
|
+
if (hasResult) {
|
|
496
|
+
this.doSearch();
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
this.endSearch();
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
nextSearchMatch() {
|
|
504
|
+
if (this.searchIterator) {
|
|
505
|
+
this.searchIterator.getNext().then((hasResult) => {
|
|
506
|
+
if (hasResult) {
|
|
507
|
+
this.doSearch();
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
previousSearchMatch() {
|
|
513
|
+
if (this.searchIterator) {
|
|
514
|
+
return this.searchIterator.getPrevious().then((hasResult) => {
|
|
515
|
+
if (hasResult) {
|
|
516
|
+
this.doSearch();
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
endSearch() {
|
|
522
|
+
if (this.searchIterator) {
|
|
523
|
+
this.searchIterator.close();
|
|
524
|
+
this.searchIterator = null;
|
|
525
|
+
this.store.search.clear();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
resetViewerMode() {
|
|
529
|
+
this.store.viewer.setDefaultMode();
|
|
530
|
+
}
|
|
531
|
+
getAnnotationsFromPage(page) {
|
|
532
|
+
return new Promise((resolve, reject) => {
|
|
533
|
+
this.pdfViewerApi
|
|
534
|
+
.getItemsFromPage(page, PdfItemCategory.ANNOTATION)
|
|
535
|
+
.then((items) => {
|
|
536
|
+
this.store.annotations.setPageAnnotations(items);
|
|
537
|
+
resolve(items);
|
|
538
|
+
})
|
|
539
|
+
.catch((err) => {
|
|
540
|
+
reject(err);
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
goToAnnotation(annotation, action) {
|
|
545
|
+
this.pdfViewerApi.goToRectangle(annotation.pdfRect);
|
|
546
|
+
if (action === 'select') {
|
|
547
|
+
this.dispatchEvent('itemSelected', annotation);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
print() {
|
|
551
|
+
this.activateModule('PrintServiceModule', null);
|
|
552
|
+
}
|
|
553
|
+
getModules() {
|
|
554
|
+
return this.modules;
|
|
555
|
+
}
|
|
556
|
+
activateModule(moduleName, args) {
|
|
557
|
+
const module = this.modules.find((m) => {
|
|
558
|
+
return m.name == moduleName;
|
|
559
|
+
});
|
|
560
|
+
if (module) {
|
|
561
|
+
module.activate(args);
|
|
562
|
+
this.dispatchEvent('moduleActivated', moduleName);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
deactivateModule(moduleName) {
|
|
566
|
+
this.dispatchEvent('moduleActivated', moduleName);
|
|
567
|
+
const module = this.modules.find((m) => {
|
|
568
|
+
return m.name == moduleName;
|
|
569
|
+
});
|
|
570
|
+
if (module) {
|
|
571
|
+
module.deactivate();
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
getSelectedText() {
|
|
575
|
+
const { textSelection, textSelectionType } = this.store.getState().viewer;
|
|
576
|
+
let text = undefined;
|
|
577
|
+
if (textSelection) {
|
|
578
|
+
const { startPoint, endPoint } = textSelection;
|
|
579
|
+
text =
|
|
580
|
+
textSelectionType === 'rectangular'
|
|
581
|
+
? this.pdfViewerApi.getTextForRectangularSelection(startPoint, endPoint)
|
|
582
|
+
: this.pdfViewerApi.getText(startPoint, endPoint);
|
|
583
|
+
}
|
|
584
|
+
return text;
|
|
585
|
+
}
|
|
586
|
+
addEventListener(type, listener) {
|
|
587
|
+
if (this.eventListeners.has(type)) {
|
|
588
|
+
;
|
|
589
|
+
this.eventListeners.get(type).push(listener);
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
this.eventListeners.set(type, [listener]);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
removeEventListener(type, listener) {
|
|
596
|
+
if (this.eventListeners.has(type)) {
|
|
597
|
+
let listeners = this.eventListeners.get(type);
|
|
598
|
+
listeners = listeners.filter((listenerInArray) => listenerInArray !== listener);
|
|
599
|
+
if (listeners.length !== 0) {
|
|
600
|
+
this.eventListeners.set(type, listeners);
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
this.eventListeners.delete(type);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
suspendCanvasEvents() {
|
|
608
|
+
this.canvasEvents.suspend();
|
|
609
|
+
}
|
|
610
|
+
resumeCanvasEvents() {
|
|
611
|
+
this.canvasEvents.resume();
|
|
612
|
+
}
|
|
613
|
+
dispatchEvent(type, args) {
|
|
614
|
+
if (this.eventListeners.has(type)) {
|
|
615
|
+
const listeners = this.eventListeners.get(type);
|
|
616
|
+
listeners.forEach((listener) => listener(args));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
getOutlines(parent) {
|
|
620
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
+
const outlineItems = yield this.pdfViewerApi.getOutlines(parent);
|
|
622
|
+
for (const item of outlineItems) {
|
|
623
|
+
if (item.hasDescendants) {
|
|
624
|
+
const children = yield this.getOutlines(item);
|
|
625
|
+
item.descendants = children;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return outlineItems;
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
openRoutine(openFunction, ...args) {
|
|
632
|
+
return new Promise((resolve, reject) => {
|
|
633
|
+
if (this.pdfViewerApi.isOpen()) {
|
|
634
|
+
this.close();
|
|
635
|
+
}
|
|
636
|
+
requestAnimationFrame(() => {
|
|
637
|
+
openFunction(...args)
|
|
638
|
+
.then(() => {
|
|
639
|
+
this.onDocumentOpened();
|
|
640
|
+
resolve({});
|
|
641
|
+
})
|
|
642
|
+
.catch((error) => {
|
|
643
|
+
if (error.message === 'The authentication failed due to a wrong password.') {
|
|
644
|
+
reject(new Error('password required'));
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
reject(new Error('unsupported file'));
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
onDocumentOpened() {
|
|
654
|
+
this.registerModules();
|
|
655
|
+
this.documentLoaded = true;
|
|
656
|
+
this.element.classList.add('pwv-ViewerCanvas--documentLoaded');
|
|
657
|
+
this.dispatchEvent('pageLayoutMode', this.pdfViewerApi.getPageLayoutMode());
|
|
658
|
+
this.dispatchEvent('firstVisiblePage', this.pdfViewerApi.getFirstVisiblePage());
|
|
659
|
+
this.dispatchEvent('lastVisiblePage', this.pdfViewerApi.getLastVisiblePage());
|
|
660
|
+
this.dispatchEvent('pageNumber', this.pdfViewerApi.getPageNumber());
|
|
661
|
+
this.dispatchEvent('zoom', this.pdfViewerApi.getZoom());
|
|
662
|
+
// set canvas size
|
|
663
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
664
|
+
this.store.canvas.resize({
|
|
665
|
+
cssWidth: containerRect.width,
|
|
666
|
+
cssHeight: containerRect.height,
|
|
667
|
+
});
|
|
668
|
+
this.startRenderLoop();
|
|
669
|
+
const document = this.store.getState().document;
|
|
670
|
+
window.setTimeout(() => {
|
|
671
|
+
this.canvasEvents.resume();
|
|
672
|
+
this.element.classList.add('pwv-ViewerCanvas--documentLoaded');
|
|
673
|
+
}, 100);
|
|
674
|
+
}
|
|
675
|
+
onDocumentClosed() {
|
|
676
|
+
this.canvasEvents.suspend();
|
|
677
|
+
this.documentLoaded = false;
|
|
678
|
+
this.element.classList.remove('pwv-ViewerCanvas--documentLoaded');
|
|
679
|
+
this.stopRenderLoop();
|
|
680
|
+
this.store.loadDefaultState();
|
|
681
|
+
}
|
|
682
|
+
startRenderLoop() {
|
|
683
|
+
const viewLayers = this.viewLayers;
|
|
684
|
+
const modules = this.modules;
|
|
685
|
+
const loop = (timestamp) => {
|
|
686
|
+
const state = this.store.getState();
|
|
687
|
+
if (this.renderLoopRunning) {
|
|
688
|
+
this.store.resetChangedState();
|
|
689
|
+
if (state.viewer.cursorStyleChanged) {
|
|
690
|
+
this.viewLayersElement.style.cursor = state.viewer.cursorStyle;
|
|
691
|
+
}
|
|
692
|
+
for (let i = 0; i < viewLayers.length; i++) {
|
|
693
|
+
const res = viewLayers[i].render(timestamp, state);
|
|
694
|
+
if (res === false) {
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
for (let i = 0; i < modules.length; i++) {
|
|
699
|
+
modules[i].render(timestamp, state);
|
|
700
|
+
}
|
|
701
|
+
requestAnimationFrame(loop);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
this.renderLoopRunning = true;
|
|
705
|
+
requestAnimationFrame(loop);
|
|
706
|
+
}
|
|
707
|
+
stopRenderLoop() {
|
|
708
|
+
this.renderLoopRunning = false;
|
|
709
|
+
}
|
|
710
|
+
registerPdfStamps(pdfStampFiles) {
|
|
711
|
+
const pdfStampConfigs = this.options.annotation.options.stamps.filter((s) => s.pdfStampFileName);
|
|
712
|
+
const pdfStampConfigMap = pdfStampConfigs.reduce(function (acc, obj) {
|
|
713
|
+
let key = obj.pdfStampFileName;
|
|
714
|
+
if (!acc[key]) {
|
|
715
|
+
acc[key] = 0;
|
|
716
|
+
}
|
|
717
|
+
++acc[key];
|
|
718
|
+
return acc;
|
|
719
|
+
}, {});
|
|
720
|
+
const onStampCreated = (pdfStamp) => {
|
|
721
|
+
if (pdfStampConfigMap.hasOwnProperty(pdfStamp.pdfStampFileName)) {
|
|
722
|
+
const stamp = this.options.annotation.options.stamps.find((s) => s.pdfStampFileName === pdfStamp.pdfStampFileName && s.pageNumber === pdfStamp.pageNumber);
|
|
723
|
+
if (stamp) {
|
|
724
|
+
stamp.thumbnail = pdfStamp.thumbnail;
|
|
725
|
+
stamp.aspectRatio = pdfStamp.aspectRatio;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
this.options.annotation.options.stamps.push(pdfStamp);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
pdfStampFiles.forEach((stampFile) => {
|
|
733
|
+
const data = imageDataUrlToUint8Array(stampFile.data);
|
|
734
|
+
const pdfStampFileName = stampFile.pdfStampFileName ? stampFile.pdfStampFileName : '';
|
|
735
|
+
this.pdfViewerApi.registerPdfStampFile(pdfStampFileName, data, onStampCreated);
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
registerModules() {
|
|
739
|
+
// view layers
|
|
740
|
+
const viewLayers = [
|
|
741
|
+
PdfDocumentLayer,
|
|
742
|
+
BusyStateLayer,
|
|
743
|
+
AnnotationSelectionLayer,
|
|
744
|
+
TextSelectionLayer,
|
|
745
|
+
ScrollLayer,
|
|
746
|
+
];
|
|
747
|
+
viewLayers.forEach((viewLayerBaseClass) => {
|
|
748
|
+
const viewLayer = new viewLayerBaseClass();
|
|
749
|
+
viewLayer.register(this, this.dispatchEvent);
|
|
750
|
+
this.viewLayers.push(viewLayer);
|
|
751
|
+
});
|
|
752
|
+
const modules = this.options.modules.filter(({ moduleInfo }) => (!moduleInfo.requiredFeatures.annotate ||
|
|
753
|
+
(moduleInfo.requiredFeatures.annotate && this.licenseFeatures.annotate)) &&
|
|
754
|
+
(!moduleInfo.requiredFeatures.fillFormFields ||
|
|
755
|
+
(moduleInfo.requiredFeatures.fillFormFields && this.licenseFeatures.fillFormFields)));
|
|
756
|
+
if (modules) {
|
|
757
|
+
modules.forEach((module) => {
|
|
758
|
+
const m = new module();
|
|
759
|
+
this.modules.push(m);
|
|
760
|
+
// tmp const for this, used for rollup
|
|
761
|
+
const viewerCanvas = this;
|
|
762
|
+
const reg = m.register(this.viewLayersElement, this.store, this.pdfViewerApi, viewerCanvas, this.options);
|
|
763
|
+
if (reg.toolbar && this.toolbarElement) {
|
|
764
|
+
this.toolbarElement.appendChild(reg.toolbar);
|
|
765
|
+
}
|
|
766
|
+
if (reg.contextbar) {
|
|
767
|
+
this.store.viewer.addContextBarItem(reg.contextbar);
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
this.updateCanvasSize();
|
|
772
|
+
}
|
|
773
|
+
unRegisterModules() {
|
|
774
|
+
this.viewLayers = [];
|
|
775
|
+
this.store.viewer.clearContextBarItems();
|
|
776
|
+
this.toolbarElement.innerHTML = '';
|
|
777
|
+
this.viewLayersElement.innerHTML = '';
|
|
778
|
+
this.modules.splice(0, this.modules.length);
|
|
779
|
+
}
|
|
780
|
+
updateViewLayerContext() {
|
|
781
|
+
const pixelRatio = window.devicePixelRatio;
|
|
782
|
+
this.store.canvas.setPixelRatio(pixelRatio);
|
|
783
|
+
const rect = this.viewLayersElement.getBoundingClientRect();
|
|
784
|
+
const maxScroll = this.pdfViewerApi.getScrollMaxPosition();
|
|
785
|
+
const scrollPosition = this.pdfViewerApi.getScrollPosition();
|
|
786
|
+
const devicePixelsWidth = rect.width * pixelRatio + (maxScroll.x > 0 ? maxScroll.x : scrollPosition.x * 2);
|
|
787
|
+
const devicePixelsHeight = rect.height * pixelRatio + (maxScroll.y > 0 ? maxScroll.y : scrollPosition.y * 2);
|
|
788
|
+
const zoom = this.pdfViewerApi.getZoom();
|
|
789
|
+
this.store.document.resize({ zoom, devicePixelsHeight, devicePixelsWidth });
|
|
790
|
+
this.store.scroll.scrollChanged({
|
|
791
|
+
cssLeft: scrollPosition.x,
|
|
792
|
+
cssTop: scrollPosition.y,
|
|
793
|
+
});
|
|
794
|
+
const state = this.store.getState();
|
|
795
|
+
const pageRects = {};
|
|
796
|
+
for (let page = this.pdfViewerApi.getFirstVisiblePage(); page <= this.pdfViewerApi.getLastVisiblePage(); page++) {
|
|
797
|
+
pageRects[page] = this.pdfViewerApi.getPageScreenRect(page);
|
|
798
|
+
}
|
|
799
|
+
this.store.document.updatePageRects(pageRects);
|
|
800
|
+
}
|
|
801
|
+
onMouseWheel(e) {
|
|
802
|
+
if (e.deltaY !== 0) {
|
|
803
|
+
if (e.ctrlKey) {
|
|
804
|
+
e.preventDefault();
|
|
805
|
+
e.cancelBubble = true;
|
|
806
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
807
|
+
const x = e.clientX - containerRect.left;
|
|
808
|
+
const y = e.clientY - containerRect.top;
|
|
809
|
+
if (e.deltaY < 0) {
|
|
810
|
+
this.zoomIn({ x, y });
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
this.zoomOut({ x, y });
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
else if (e.shiftKey) {
|
|
817
|
+
e.preventDefault();
|
|
818
|
+
e.cancelBubble = true;
|
|
819
|
+
const distance = e.deltaY > 0 ? 100 : -100;
|
|
820
|
+
this.scrollRight(distance);
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
e.preventDefault();
|
|
824
|
+
e.cancelBubble = true;
|
|
825
|
+
const distance = e.deltaY > 0 ? 100 : -100;
|
|
826
|
+
this.scrollDown(distance);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
else if (e.deltaX > 0) {
|
|
830
|
+
this.scrollRight();
|
|
831
|
+
}
|
|
832
|
+
else if (e.deltaX < 0) {
|
|
833
|
+
this.scrollLeft();
|
|
834
|
+
}
|
|
835
|
+
else if (e.deltaZ < 0) {
|
|
836
|
+
this.zoomIn();
|
|
837
|
+
}
|
|
838
|
+
else if (e.deltaZ > 0) {
|
|
839
|
+
this.zoomOut();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
transformPointer(e) {
|
|
843
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
844
|
+
const x = e.clientX - containerRect.left;
|
|
845
|
+
const y = e.clientY - containerRect.top;
|
|
846
|
+
return {
|
|
847
|
+
cssX: x,
|
|
848
|
+
cssY: y,
|
|
849
|
+
isDown: e.buttons === 1,
|
|
850
|
+
type: e.type,
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
onCanvasPointerClick(e) {
|
|
854
|
+
const p = this.transformPointer(e);
|
|
855
|
+
this.store.pointer.update(p);
|
|
856
|
+
this.store.pointer.setAction('click');
|
|
857
|
+
}
|
|
858
|
+
onCanvasPointerDblClick(e) {
|
|
859
|
+
const p = this.transformPointer(e);
|
|
860
|
+
this.store.pointer.update(p);
|
|
861
|
+
this.store.pointer.setAction('dblclick');
|
|
862
|
+
}
|
|
863
|
+
onCanvasPointerLongPress(e) {
|
|
864
|
+
const p = this.transformPointer(e);
|
|
865
|
+
this.store.pointer.update(p);
|
|
866
|
+
this.store.pointer.setAction('longpress');
|
|
867
|
+
}
|
|
868
|
+
onCanvasPointerStartDrag(e) {
|
|
869
|
+
this.store.pointer.setAction('startdrag');
|
|
870
|
+
}
|
|
871
|
+
onCanvasPointerEndDrag(e) {
|
|
872
|
+
this.store.pointer.setAction('enddrag');
|
|
873
|
+
}
|
|
874
|
+
onCanvasPointerPinch(e) {
|
|
875
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
876
|
+
const x = (e.clientX - containerRect.left) * devicePixelRatio;
|
|
877
|
+
const y = (e.clientY - containerRect.top) * devicePixelRatio;
|
|
878
|
+
const zoom = this.pdfViewerApi.getZoom();
|
|
879
|
+
const zoomDistance = (e.movementDistance / 200) * zoom;
|
|
880
|
+
let newZoom = zoom + zoomDistance;
|
|
881
|
+
const minZoomLevel = this.options.viewer.general.defaultZoomLevels[0];
|
|
882
|
+
const maxZoomLevel = this.options.viewer.general.defaultZoomLevels[this.options.viewer.general.defaultZoomLevels.length - 1];
|
|
883
|
+
if (newZoom < minZoomLevel) {
|
|
884
|
+
newZoom = minZoomLevel;
|
|
885
|
+
}
|
|
886
|
+
else if (newZoom > maxZoomLevel) {
|
|
887
|
+
newZoom = maxZoomLevel;
|
|
888
|
+
}
|
|
889
|
+
this.setZoom(newZoom, { x, y });
|
|
890
|
+
}
|
|
891
|
+
onCanvasPointerDown(e) {
|
|
892
|
+
const p = this.transformPointer(e);
|
|
893
|
+
this.store.pointer.update(p);
|
|
894
|
+
this.store.startPointer.update(p);
|
|
895
|
+
}
|
|
896
|
+
onCanvasPointerUp(e) {
|
|
897
|
+
const p = this.transformPointer(e);
|
|
898
|
+
this.store.pointer.update(p);
|
|
899
|
+
}
|
|
900
|
+
onCanvasPointerMove(e) {
|
|
901
|
+
if (e.buttons < 2) {
|
|
902
|
+
const p = this.transformPointer(e);
|
|
903
|
+
this.store.pointer.update(p);
|
|
904
|
+
}
|
|
905
|
+
else if (e.buttons === 4) {
|
|
906
|
+
this.scrollMove(e.movementY * -1, e.movementX * -1);
|
|
907
|
+
this.store.viewer.setCursorStyle(CursorStyle.GRABBING);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
onKeyboardShortcuts(e) {
|
|
911
|
+
// check if element is visible
|
|
912
|
+
const rect = this.element.getBoundingClientRect();
|
|
913
|
+
if (rect.width + rect.height === 0) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
let metaflag = false;
|
|
917
|
+
// metaKey is true if it is super/command key in this context
|
|
918
|
+
// although meta key is normally alt
|
|
919
|
+
if (e.metaKey) {
|
|
920
|
+
metaflag = true;
|
|
921
|
+
}
|
|
922
|
+
const { shortcuts } = this.options;
|
|
923
|
+
if (Object.keys(shortcuts).length > 0) {
|
|
924
|
+
const keyboardCommands = getKeyboardCommands(e, shortcuts);
|
|
925
|
+
if (!keyboardCommands.length) {
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
for (const cmd of keyboardCommands) {
|
|
929
|
+
// deal with super / command key in a central place
|
|
930
|
+
// it is not a modifier, but it behaves like one
|
|
931
|
+
const isSuperKeyRequired = cmd[1];
|
|
932
|
+
if (isSuperKeyRequired && !metaflag) {
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
935
|
+
switch (cmd[0]) {
|
|
936
|
+
case 'zoomIn':
|
|
937
|
+
e.preventDefault();
|
|
938
|
+
this.zoomIn();
|
|
939
|
+
break;
|
|
940
|
+
case 'zoomOut':
|
|
941
|
+
e.preventDefault();
|
|
942
|
+
this.zoomOut();
|
|
943
|
+
break;
|
|
944
|
+
case 'nextPage':
|
|
945
|
+
e.preventDefault();
|
|
946
|
+
this.nextPage();
|
|
947
|
+
break;
|
|
948
|
+
case 'previousPage':
|
|
949
|
+
e.preventDefault();
|
|
950
|
+
this.previousPage();
|
|
951
|
+
break;
|
|
952
|
+
case 'scrollDown':
|
|
953
|
+
e.preventDefault();
|
|
954
|
+
this.scrollDown();
|
|
955
|
+
break;
|
|
956
|
+
case 'scrollUp':
|
|
957
|
+
e.preventDefault();
|
|
958
|
+
this.scrollUp();
|
|
959
|
+
break;
|
|
960
|
+
case 'scrollLeft':
|
|
961
|
+
e.preventDefault();
|
|
962
|
+
this.scrollLeft();
|
|
963
|
+
break;
|
|
964
|
+
case 'scrollRight':
|
|
965
|
+
e.preventDefault();
|
|
966
|
+
this.scrollRight();
|
|
967
|
+
break;
|
|
968
|
+
case 'firstPage':
|
|
969
|
+
e.preventDefault();
|
|
970
|
+
this.setPageNumber(1);
|
|
971
|
+
break;
|
|
972
|
+
case 'lastPage':
|
|
973
|
+
e.preventDefault();
|
|
974
|
+
this.setPageNumber(this.getPageCount());
|
|
975
|
+
break;
|
|
976
|
+
case 'releaseSelection':
|
|
977
|
+
const viewerMode = this.store.getState().viewer.mode;
|
|
978
|
+
if (viewerMode === ViewerMode.TEXT_SELECTED) {
|
|
979
|
+
e.preventDefault();
|
|
980
|
+
e.cancelBubble = true;
|
|
981
|
+
this.store.viewer.setTextSelection({ selection: null, type: null });
|
|
982
|
+
this.store.viewer.setTextSelectionState(null);
|
|
983
|
+
break;
|
|
984
|
+
}
|
|
985
|
+
if (viewerMode === ViewerMode.ANNOTATION_SELECTED) {
|
|
986
|
+
e.preventDefault();
|
|
987
|
+
e.cancelBubble = true;
|
|
988
|
+
this.store.viewer.deselectAnnotation();
|
|
989
|
+
break;
|
|
990
|
+
}
|
|
991
|
+
break;
|
|
992
|
+
case 'copy':
|
|
993
|
+
if (this.options.viewer.permissions.allowCopyText) {
|
|
994
|
+
const documentSelection = document.getSelection();
|
|
995
|
+
// Copy needs to work outside the viewer too
|
|
996
|
+
// None if inside the viewer: Caret|Range outside
|
|
997
|
+
if ((documentSelection === null || documentSelection === void 0 ? void 0 : documentSelection.type) && ['Caret', 'Range'].includes(documentSelection === null || documentSelection === void 0 ? void 0 : documentSelection.type)) {
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
e.preventDefault();
|
|
1001
|
+
e.cancelBubble = true;
|
|
1002
|
+
copyTextToClipboard(this.getSelectedText() || '');
|
|
1003
|
+
}
|
|
1004
|
+
break;
|
|
1005
|
+
case 'copyMac':
|
|
1006
|
+
if (this.options.viewer.permissions.allowCopyText) {
|
|
1007
|
+
const documentSelection = document.getSelection();
|
|
1008
|
+
// Copy needs to work outside the viewer too
|
|
1009
|
+
// None if inside the viewer: Caret|Range outside
|
|
1010
|
+
if ((documentSelection === null || documentSelection === void 0 ? void 0 : documentSelection.type) && ['Caret', 'Range'].includes(documentSelection === null || documentSelection === void 0 ? void 0 : documentSelection.type)) {
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
e.preventDefault();
|
|
1014
|
+
e.cancelBubble = true;
|
|
1015
|
+
copyTextToClipboard(this.getSelectedText() || '');
|
|
1016
|
+
}
|
|
1017
|
+
break;
|
|
1018
|
+
case 'resetZoom':
|
|
1019
|
+
e.preventDefault();
|
|
1020
|
+
this.setZoom(1);
|
|
1021
|
+
break;
|
|
1022
|
+
case 'fitToPage':
|
|
1023
|
+
e.preventDefault();
|
|
1024
|
+
this.setFitMode(PdfFitMode.FIT_PAGE);
|
|
1025
|
+
break;
|
|
1026
|
+
case 'fitToWidth':
|
|
1027
|
+
e.preventDefault();
|
|
1028
|
+
this.setFitMode(PdfFitMode.FIT_WIDTH);
|
|
1029
|
+
break;
|
|
1030
|
+
case 'rotateView':
|
|
1031
|
+
if (this.options.viewer.permissions.allowRotateView) {
|
|
1032
|
+
e.preventDefault();
|
|
1033
|
+
const r = this.getRotation();
|
|
1034
|
+
const rotation = r >= 270 ? 0 : r + 90;
|
|
1035
|
+
this.setRotation(rotation);
|
|
1036
|
+
}
|
|
1037
|
+
break;
|
|
1038
|
+
case 'cancelEditAnnotation':
|
|
1039
|
+
const { selectedModuleName } = this.store.getState().viewer;
|
|
1040
|
+
if (selectedModuleName) {
|
|
1041
|
+
this.store.viewer.endModule(selectedModuleName);
|
|
1042
|
+
e.preventDefault();
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
else if (e.key === 'Escape') {
|
|
1049
|
+
const { selectedModuleName, mode } = this.store.getState().viewer;
|
|
1050
|
+
if (selectedModuleName) {
|
|
1051
|
+
this.store.viewer.endModule(selectedModuleName);
|
|
1052
|
+
}
|
|
1053
|
+
const viewerMode = mode;
|
|
1054
|
+
if (viewerMode === ViewerMode.TEXT_SELECTED) {
|
|
1055
|
+
this.store.viewer.setTextSelection({ selection: null, type: null });
|
|
1056
|
+
this.store.viewer.setTextSelectionState(null);
|
|
1057
|
+
}
|
|
1058
|
+
if (viewerMode === ViewerMode.ANNOTATION_SELECTED) {
|
|
1059
|
+
this.store.viewer.deselectAnnotation();
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
onResize(entries, observer) {
|
|
1064
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
1065
|
+
if (containerRect.width === 0 || containerRect.height === 0) {
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
this.updateCanvasSize();
|
|
1069
|
+
}
|
|
1070
|
+
onHtmlDocumentSelectionChanged() {
|
|
1071
|
+
const documentSelection = document.getSelection();
|
|
1072
|
+
if (documentSelection) {
|
|
1073
|
+
const viewerMode = this.store.getState().viewer.mode;
|
|
1074
|
+
if (viewerMode === ViewerMode.TEXT_SELECTED) {
|
|
1075
|
+
this.store.viewer.setTextSelection({ selection: null, type: null });
|
|
1076
|
+
this.store.viewer.setTextSelectionState(null);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
updateCanvasSize() {
|
|
1081
|
+
const containerRect = this.viewLayersElement.getBoundingClientRect();
|
|
1082
|
+
const pixelRatio = window.devicePixelRatio;
|
|
1083
|
+
this.viewLayers.forEach((viewLayer) => {
|
|
1084
|
+
viewLayer.resize(containerRect.width, containerRect.height, pixelRatio);
|
|
1085
|
+
});
|
|
1086
|
+
this.modules.forEach((module) => {
|
|
1087
|
+
module.resize(containerRect.width, containerRect.height);
|
|
1088
|
+
});
|
|
1089
|
+
this.store.canvas.resize({
|
|
1090
|
+
cssWidth: containerRect.width,
|
|
1091
|
+
cssHeight: containerRect.height,
|
|
1092
|
+
});
|
|
1093
|
+
this.store.canvas.setCanvasInvalidated(true);
|
|
1094
|
+
}
|
|
1095
|
+
onCanvasInvalidated() {
|
|
1096
|
+
this.store.canvas.setCanvasInvalidated(true);
|
|
1097
|
+
this.updateViewLayerContext();
|
|
1098
|
+
}
|
|
1099
|
+
onFirstVisiblePageChanged(page) {
|
|
1100
|
+
this.store.document.fistVisiblePageChanged(page);
|
|
1101
|
+
this.maybeGetAnnotations(this.store.getState().document.firstVisiblePage, this.store.getState().document.lastVisiblePage);
|
|
1102
|
+
this.dispatchEvent('firstVisiblePage', page);
|
|
1103
|
+
}
|
|
1104
|
+
onPageNumberChanged(page) {
|
|
1105
|
+
this.dispatchEvent('pageNumber', page);
|
|
1106
|
+
}
|
|
1107
|
+
onTextSelected() {
|
|
1108
|
+
var _a;
|
|
1109
|
+
this.dispatchEvent('textSelected', (_a = this.getSelectedText()) !== null && _a !== void 0 ? _a : '');
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* This function works with a timer. This avoids mass loading of annotation when scrolling
|
|
1113
|
+
* through a large document. It only loads the annotations once the viewport is stable (visible
|
|
1114
|
+
* pages didn't change for 100ms). If there is an active timer that will be cancelled.
|
|
1115
|
+
* @param begin first page to get annotations from
|
|
1116
|
+
* @param end last page to get annotations from
|
|
1117
|
+
*/
|
|
1118
|
+
maybeGetAnnotations(begin, end) {
|
|
1119
|
+
if (this.annotTimer) {
|
|
1120
|
+
window.clearTimeout(this.annotTimer);
|
|
1121
|
+
}
|
|
1122
|
+
this.annotTimer = window.setTimeout(() => {
|
|
1123
|
+
this.getAnnotations(begin, end);
|
|
1124
|
+
}, 100);
|
|
1125
|
+
}
|
|
1126
|
+
getAnnotations(begin, end) {
|
|
1127
|
+
for (let page = begin; page <= end; page++) {
|
|
1128
|
+
if (this.store.getState().annotations.byPage[page] === undefined) {
|
|
1129
|
+
this.pdfViewerApi
|
|
1130
|
+
.getItemsFromPage(page, PdfItemCategory.ANNOTATION)
|
|
1131
|
+
.then((itemsOnPage) => {
|
|
1132
|
+
this.store.annotations.setPageAnnotations(itemsOnPage);
|
|
1133
|
+
})
|
|
1134
|
+
.catch((err) => {
|
|
1135
|
+
console.warn(err);
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
onLastVisiblePageChanged(page) {
|
|
1141
|
+
this.store.document.lastVisiblePageChanged(page);
|
|
1142
|
+
this.maybeGetAnnotations(this.store.getState().document.firstVisiblePage, this.store.getState().document.lastVisiblePage);
|
|
1143
|
+
this.dispatchEvent('lastVisiblePage', page);
|
|
1144
|
+
}
|
|
1145
|
+
onZoomChanged(zoom) {
|
|
1146
|
+
this.dispatchEvent('zoom', zoom);
|
|
1147
|
+
}
|
|
1148
|
+
onFitModeChanged(fitMode) {
|
|
1149
|
+
this.store.document.fitModeChanged(fitMode);
|
|
1150
|
+
this.dispatchEvent('fitMode', fitMode);
|
|
1151
|
+
}
|
|
1152
|
+
onPageLayoutModeChanged(layoutMode) {
|
|
1153
|
+
this.store.document.pageLayoutModeChanged(layoutMode);
|
|
1154
|
+
this.dispatchEvent('pageLayoutMode', layoutMode);
|
|
1155
|
+
}
|
|
1156
|
+
onBusyStateChanged(state) {
|
|
1157
|
+
this.store.document.busyStateChanged(state);
|
|
1158
|
+
if (state) {
|
|
1159
|
+
this.element.classList.remove('pwv-ViewerCanvas--documentIdle');
|
|
1160
|
+
}
|
|
1161
|
+
else {
|
|
1162
|
+
this.element.classList.add('pwv-ViewerCanvas--documentIdle');
|
|
1163
|
+
}
|
|
1164
|
+
this.dispatchEvent('busyState', state);
|
|
1165
|
+
}
|
|
1166
|
+
onRotationChanged(rotation) {
|
|
1167
|
+
this.store.document.rotationChanged(rotation);
|
|
1168
|
+
this.dispatchEvent('rotation', rotation);
|
|
1169
|
+
}
|
|
1170
|
+
onItemCreated(item) {
|
|
1171
|
+
if (item.itemCategory === PdfItemCategory.ANNOTATION) {
|
|
1172
|
+
this.store.annotations.addAnnotation(item);
|
|
1173
|
+
}
|
|
1174
|
+
this.dispatchEvent('itemCreated', item);
|
|
1175
|
+
}
|
|
1176
|
+
onItemUpdated(item) {
|
|
1177
|
+
if (item.itemCategory === PdfItemCategory.ANNOTATION) {
|
|
1178
|
+
this.store.annotations.updateAnnotation(item);
|
|
1179
|
+
}
|
|
1180
|
+
this.dispatchEvent('itemUpdated', item);
|
|
1181
|
+
}
|
|
1182
|
+
onItemDeleted(deletedItem) {
|
|
1183
|
+
if (deletedItem.categoryType === PdfItemCategory.ANNOTATION) {
|
|
1184
|
+
this.store.annotations.deleteAnnotation(deletedItem.id);
|
|
1185
|
+
}
|
|
1186
|
+
this.dispatchEvent('itemDeleted', deletedItem);
|
|
1187
|
+
}
|
|
1188
|
+
onPageChanged(pageNumber) {
|
|
1189
|
+
this.pdfViewerApi
|
|
1190
|
+
.getItemsFromPage(pageNumber, PdfItemCategory.ANNOTATION)
|
|
1191
|
+
.then((itemsOnPage) => {
|
|
1192
|
+
itemsOnPage.items.forEach((annotation) => {
|
|
1193
|
+
this.store.annotations.updateAnnotation(annotation);
|
|
1194
|
+
});
|
|
1195
|
+
this.dispatchEvent('pageChanged', pageNumber);
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
onApiError(error) {
|
|
1199
|
+
console.error('//// PdfViewerApi Error: ', error);
|
|
1200
|
+
this.dispatchEvent('error', error);
|
|
1201
|
+
}
|
|
1202
|
+
beforeUnloadCallback(e) {
|
|
1203
|
+
const changes = this.pdfViewerApi.hasChanges();
|
|
1204
|
+
if (changes !== null && changes !== DocumentChange.NONE) {
|
|
1205
|
+
e.preventDefault();
|
|
1206
|
+
e.returnValue = '';
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
getNextZoomOutLevel(zoomCurrent) {
|
|
1213
|
+
for (var i = this.options.viewer.general.defaultZoomLevels.length - 1; i >= 0; i--) {
|
|
1214
|
+
if (zoomCurrent > this.options.viewer.general.defaultZoomLevels[i])
|
|
1215
|
+
return this.options.viewer.general.defaultZoomLevels[i];
|
|
1216
|
+
}
|
|
1217
|
+
return this.options.viewer.general.defaultZoomLevels[0];
|
|
1218
|
+
}
|
|
1219
|
+
getNextZoomInLevel(zoomCurrent) {
|
|
1220
|
+
for (var i = 0; i < this.options.viewer.general.defaultZoomLevels.length; i++) {
|
|
1221
|
+
if (zoomCurrent < this.options.viewer.general.defaultZoomLevels[i])
|
|
1222
|
+
return this.options.viewer.general.defaultZoomLevels[i];
|
|
1223
|
+
}
|
|
1224
|
+
return this.options.viewer.general.defaultZoomLevels[this.options.viewer.general.defaultZoomLevels.length - 1];
|
|
1225
|
+
}
|
|
1226
|
+
}
|