@progress/kendo-pdfviewer-common 0.5.0-develop.1 → 0.5.0-develop.3

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.
Files changed (35) hide show
  1. package/dist/es/annotations/annotation-editor-layer-builder.js +6 -1
  2. package/dist/es/annotations/annotation-layer-builder.js +12 -2
  3. package/dist/es/annotations/annotation-layer.js +6 -0
  4. package/dist/es/annotations/draw-layer-builder.js +5 -1
  5. package/dist/es/annotations/helpers/text-accessibility-manager.js +5 -0
  6. package/dist/es/text/text-layer-builder.js +13 -1
  7. package/dist/es/utils.js +1 -0
  8. package/dist/es/widget/page.js +21 -0
  9. package/dist/es/widget/pdfviewer.js +10 -9
  10. package/dist/es2015/annotations/annotation-editor-layer-builder.js +6 -1
  11. package/dist/es2015/annotations/annotation-layer-builder.js +12 -2
  12. package/dist/es2015/annotations/annotation-layer.js +6 -0
  13. package/dist/es2015/annotations/draw-layer-builder.js +5 -1
  14. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +5 -0
  15. package/dist/es2015/text/text-layer-builder.js +13 -1
  16. package/dist/es2015/utils.js +1 -0
  17. package/dist/es2015/widget/page.js +21 -0
  18. package/dist/es2015/widget/pdfviewer.js +10 -9
  19. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +3 -1
  20. package/dist/npm/annotations/annotation-editor-layer-builder.js +6 -1
  21. package/dist/npm/annotations/annotation-layer-builder.d.ts +3 -1
  22. package/dist/npm/annotations/annotation-layer-builder.js +12 -2
  23. package/dist/npm/annotations/annotation-layer.d.ts +3 -1
  24. package/dist/npm/annotations/annotation-layer.js +6 -0
  25. package/dist/npm/annotations/draw-layer-builder.d.ts +3 -1
  26. package/dist/npm/annotations/draw-layer-builder.js +5 -1
  27. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +1 -0
  28. package/dist/npm/annotations/helpers/text-accessibility-manager.js +5 -0
  29. package/dist/npm/text/text-layer-builder.d.ts +3 -1
  30. package/dist/npm/text/text-layer-builder.js +13 -1
  31. package/dist/npm/utils.d.ts +1 -0
  32. package/dist/npm/utils.js +3 -1
  33. package/dist/npm/widget/page.js +21 -0
  34. package/dist/npm/widget/pdfviewer.js +9 -8
  35. package/package.json +1 -1
@@ -112,11 +112,12 @@ class AnnotationEditorLayerBuilder {
112
112
  });
113
113
  }
114
114
  cancel() {
115
+ var _a;
115
116
  this._cancelled = true;
116
117
  if (!this.div) {
117
118
  return;
118
119
  }
119
- this.annotationEditorLayer.destroy();
120
+ (_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
120
121
  }
121
122
  hide() {
122
123
  if (!this.div) {
@@ -130,6 +131,10 @@ class AnnotationEditorLayerBuilder {
130
131
  }
131
132
  this.div.hidden = false;
132
133
  }
134
+ destroy() {
135
+ var _a;
136
+ (_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
137
+ }
133
138
  }
134
139
  _AnnotationEditorLayerBuilder_annotationLayer = new WeakMap(), _AnnotationEditorLayerBuilder_drawLayer = new WeakMap(), _AnnotationEditorLayerBuilder_onAppend = new WeakMap(), _AnnotationEditorLayerBuilder_textLayer = new WeakMap(), _AnnotationEditorLayerBuilder_uiManager = new WeakMap();
135
140
  export { AnnotationEditorLayerBuilder };
@@ -143,8 +143,8 @@ class AnnotationLayerBuilder {
143
143
  (_b = __classPrivateFieldGet(this, _AnnotationLayerBuilder_onAppend, "f")) === null || _b === void 0 ? void 0 : _b.call(this, div);
144
144
  this.annotationLayer = new AnnotationLayer({
145
145
  div,
146
- // accessibilityManager: this._accessibilityManager,
147
- accessibilityManager: null,
146
+ accessibilityManager: this._accessibilityManager,
147
+ // accessibilityManager: null,
148
148
  annotationCanvasMap: this._annotationCanvasMap,
149
149
  annotationEditorUIManager: this._annotationEditorUIManager,
150
150
  page: this.pdfPage,
@@ -190,6 +190,16 @@ class AnnotationLayerBuilder {
190
190
  var _a;
191
191
  return !!((_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.hasEditableAnnotations());
192
192
  }
193
+ destroy() {
194
+ var _a, _b, _c;
195
+ this.cancel();
196
+ (_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.destroy();
197
+ this.annotationLayer = null;
198
+ (_b = __classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f")) === null || _b === void 0 ? void 0 : _b.abort();
199
+ __classPrivateFieldSet(this, _AnnotationLayerBuilder_eventAbortController, null, "f");
200
+ (_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
201
+ this.div = null;
202
+ }
193
203
  }
194
204
  _AnnotationLayerBuilder_onAppend = new WeakMap(), _AnnotationLayerBuilder_eventAbortController = new WeakMap(), _AnnotationLayerBuilder_instances = new WeakSet(), _AnnotationLayerBuilder_updatePresentationModeState = function _AnnotationLayerBuilder_updatePresentationModeState(state) {
195
205
  if (!this.div) {
@@ -2766,6 +2766,12 @@ class AnnotationLayer {
2766
2766
  getEditableAnnotation(id) {
2767
2767
  return __classPrivateFieldGet(this, _AnnotationLayer_editableAnnotations, "f").get(id);
2768
2768
  }
2769
+ destroy() {
2770
+ var _a, _b;
2771
+ (_a = __classPrivateFieldGet(this, _AnnotationLayer_annotationCanvasMap, "f")) === null || _a === void 0 ? void 0 : _a.clear();
2772
+ (_b = this.div) === null || _b === void 0 ? void 0 : _b.remove();
2773
+ this.div = null;
2774
+ }
2769
2775
  }
2770
2776
  _AnnotationLayer_accessibilityManager = new WeakMap(), _AnnotationLayer_annotationCanvasMap = new WeakMap(), _AnnotationLayer_editableAnnotations = new WeakMap(), _AnnotationLayer_instances = new WeakSet(), _AnnotationLayer_appendElement = function _AnnotationLayer_appendElement(element, id) {
2771
2777
  var _a;
@@ -47,10 +47,11 @@ class DrawLayerBuilder {
47
47
  }
48
48
  cancel() {
49
49
  // this._cancelled = true;
50
+ var _a;
50
51
  if (!__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
51
52
  return;
52
53
  }
53
- __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f").destroy();
54
+ (_a = __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) === null || _a === void 0 ? void 0 : _a.destroy();
54
55
  __classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, null, "f");
55
56
  }
56
57
  setParent(parent) {
@@ -60,6 +61,9 @@ class DrawLayerBuilder {
60
61
  getDrawLayer() {
61
62
  return __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f");
62
63
  }
64
+ destroy() {
65
+ this.cancel();
66
+ }
63
67
  }
64
68
  _DrawLayerBuilder_drawLayer = new WeakMap();
65
69
  export { DrawLayerBuilder };
@@ -178,6 +178,11 @@ class TextAccessibilityManager {
178
178
  }
179
179
  return id;
180
180
  }
181
+ destroy() {
182
+ __classPrivateFieldSet(this, _TextAccessibilityManager_textNodes, new Map(), "f");
183
+ __classPrivateFieldSet(this, _TextAccessibilityManager_waitingElements, new Map(), "f");
184
+ __classPrivateFieldSet(this, _TextAccessibilityManager_textChildren, null, "f");
185
+ }
181
186
  }
182
187
  _a = TextAccessibilityManager, _TextAccessibilityManager_enabled = new WeakMap(), _TextAccessibilityManager_textChildren = new WeakMap(), _TextAccessibilityManager_textNodes = new WeakMap(), _TextAccessibilityManager_waitingElements = new WeakMap(), _TextAccessibilityManager_instances = new WeakSet(), _TextAccessibilityManager_compareElementPositions = function _TextAccessibilityManager_compareElementPositions(e1, e2) {
183
188
  const rect1 = e1.getBoundingClientRect();
@@ -124,13 +124,25 @@ class TextLayerBuilder {
124
124
  * Cancel rendering of the text layer.
125
125
  */
126
126
  cancel() {
127
- var _b, _c;
127
+ var _b, _c, _d;
128
128
  (_b = __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f")) === null || _b === void 0 ? void 0 : _b.cancel();
129
129
  __classPrivateFieldSet(this, _TextLayerBuilder_textLayer, null, "f");
130
130
  // this.highlighter?.disable();
131
131
  (_c = this.accessibilityManager) === null || _c === void 0 ? void 0 : _c.disable();
132
+ (_d = this.accessibilityManager) === null || _d === void 0 ? void 0 : _d.destroy();
132
133
  __classPrivateFieldGet(_a, _a, "m", _TextLayerBuilder_removeGlobalSelectionListener).call(_a, this.div);
133
134
  }
135
+ destroy() {
136
+ var _b, _c;
137
+ TextLayer.cleanup();
138
+ this.cancel();
139
+ this.pdfPage = null;
140
+ // this.highlighter = null;
141
+ (_b = this.accessibilityManager) === null || _b === void 0 ? void 0 : _b.destroy();
142
+ this.accessibilityManager = null;
143
+ (_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
144
+ this.div = null;
145
+ }
134
146
  }
135
147
  _a = TextLayerBuilder, _TextLayerBuilder_onAppend = new WeakMap(), _TextLayerBuilder_textLayer = new WeakMap(), _TextLayerBuilder_instances = new WeakSet(), _TextLayerBuilder_bindMouse = function _TextLayerBuilder_bindMouse(end) {
136
148
  const { div } = this;
package/dist/es/utils.js CHANGED
@@ -482,3 +482,4 @@ const createCanvas = (page, zoom = 1, cssClass = '') => {
482
482
  styles
483
483
  };
484
484
  };
485
+ export const getDevicePixelRatio = () => (window === null || window === void 0 ? void 0 : window.devicePixelRatio) || 1;
@@ -96,9 +96,27 @@ export class Page extends Component {
96
96
  this.resetState();
97
97
  }
98
98
  destroy() {
99
+ var _a, _b, _c, _d, _e;
99
100
  this.destroyTextLayer();
101
+ if (this.canvas) {
102
+ this.canvas.width = 0;
103
+ this.canvas.height = 0;
104
+ this.canvas.remove();
105
+ this.canvas = null;
106
+ }
107
+ if (this.canvasForPrint) {
108
+ this.canvasForPrint.width = 0;
109
+ this.canvasForPrint.height = 0;
110
+ this.canvasForPrint.remove();
111
+ this.canvasForPrint = null;
112
+ }
113
+ (_a = this.drawLayer) === null || _a === void 0 ? void 0 : _a.destroy();
114
+ (_b = this.annotationLayer) === null || _b === void 0 ? void 0 : _b.destroy();
115
+ (_c = this.annotationEditorLayer) === null || _c === void 0 ? void 0 : _c.destroy();
116
+ (_d = this.div) === null || _d === void 0 ? void 0 : _d.remove();
100
117
  this.div = null;
101
118
  this.pdfViewer = null;
119
+ (_e = this.pdfPage) === null || _e === void 0 ? void 0 : _e.cleanup();
102
120
  this.pdfPage = null;
103
121
  }
104
122
  get isEditing() {
@@ -129,6 +147,9 @@ export class Page extends Component {
129
147
  return viewport;
130
148
  }
131
149
  destroyTextLayer() {
150
+ var _a, _b;
151
+ (_a = this.textLayer) === null || _a === void 0 ? void 0 : _a.cancel();
152
+ (_b = this.textLayer) === null || _b === void 0 ? void 0 : _b.destroy();
132
153
  this.removeTextLayer();
133
154
  this.textLayer = null;
134
155
  }
@@ -1,7 +1,7 @@
1
1
  var _PdfViewer_instances, _PdfViewer_annotationEditorMode, _PdfViewer_switchAnnotationEditorModeTimeoutId, _PdfViewer_annotationMode, _PdfViewer_eventAbortController, _PdfViewer_onPageRenderedCallback, _PdfViewer_switchToEditAnnotationMode, _PdfViewer_scrollIntoView;
2
2
  import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
3
  import { deepExtend, Component, isString, toArray, noop, hasValue, toClassSelector, addClass, removeClass, mousewheelDelta, convertToHtml, clamp, createPromise } from "../common/main";
4
- import { currentPage, parsePdfFromBase64String, scale as getRenderScale, adjustCanvasSize, createElement } from "../utils";
4
+ import { currentPage, parsePdfFromBase64String, adjustCanvasSize, createElement, getDevicePixelRatio } from "../utils";
5
5
  import { SearchService } from "../search";
6
6
  import { Scroller, throttle } from "../scroller";
7
7
  import { saveAs } from "@progress/kendo-file-saver";
@@ -61,6 +61,7 @@ export class PdfViewer extends Component {
61
61
  pageWheelThrottleDelay: 200,
62
62
  // ported from pdf.js
63
63
  printResolution: 100,
64
+ renderScale: 1.4,
64
65
  loadOnDemand: false,
65
66
  loadOnDemandPageSize: 2,
66
67
  messages: {
@@ -78,6 +79,7 @@ export class PdfViewer extends Component {
78
79
  },
79
80
  elementSelectors: {
80
81
  pageSelector: "k-page:not(.k-blank-page)",
82
+ anyPageSelector: "k-page",
81
83
  pagesContainerClass: "k-pdf-viewer-pages",
82
84
  pageCanvasWrapper: "k-canvas-wrapper",
83
85
  documentContainerClass: "k-pdf-viewer-canvas",
@@ -219,6 +221,7 @@ export class PdfViewer extends Component {
219
221
  return;
220
222
  }
221
223
  e.preventDefault();
224
+ e.stopPropagation();
222
225
  const wheelDelta = mousewheelDelta(e);
223
226
  const zoomModifier = wheelDelta < 0 ? 1 : -1;
224
227
  const zoomLevel = this.state.zoomLevel + (zoomModifier * this.options.zoomRate);
@@ -746,20 +749,15 @@ export class PdfViewer extends Component {
746
749
  if (zoom <= 0) {
747
750
  return;
748
751
  }
749
- const renderScale = getRenderScale();
752
+ const renderScale = this.options.renderScale * getDevicePixelRatio();
750
753
  let scaleNum = zoom * renderScale;
751
754
  if (printUnits) {
752
755
  scaleNum = zoom || renderScale;
753
756
  }
754
- // const scaleNum = zoom * renderScale;
755
757
  // changing the viewport dimensions here requires changes in
756
758
  // page.getPrintContentAsync for the printing dimensions
757
759
  const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
758
760
  const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
759
- // const styles = {
760
- // width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
761
- // height: Math.floor(viewport.height / scaleNum) * zoom + 'pt'
762
- // };
763
761
  // use PageView.setLayerDimensions
764
762
  const { pageWidth, pageHeight } = viewport.rawDims;
765
763
  const styles = {
@@ -1019,9 +1017,12 @@ export class PdfViewer extends Component {
1019
1017
  }
1020
1018
  calculateZoomLevel({ zoomLevel, zoomLevelType, currentZoom }) {
1021
1019
  const documentContainer = this.getDocumentContainer();
1022
- const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.pageSelector));
1023
- const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
1020
+ const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.anyPageSelector));
1024
1021
  let calculatedZoomLevel = clamp(zoomLevel || DEFAULT_ZOOM_LEVEL, this.options.minZoom, this.options.maxZoom);
1022
+ if (!hasValue(page)) {
1023
+ return calculatedZoomLevel;
1024
+ }
1025
+ const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
1025
1026
  if (zoomLevelType === "ActualWidth" || zoomLevelType === "actualWidth") {
1026
1027
  calculatedZoomLevel = 1;
1027
1028
  }
@@ -112,11 +112,12 @@ class AnnotationEditorLayerBuilder {
112
112
  });
113
113
  }
114
114
  cancel() {
115
+ var _a;
115
116
  this._cancelled = true;
116
117
  if (!this.div) {
117
118
  return;
118
119
  }
119
- this.annotationEditorLayer.destroy();
120
+ (_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
120
121
  }
121
122
  hide() {
122
123
  if (!this.div) {
@@ -130,6 +131,10 @@ class AnnotationEditorLayerBuilder {
130
131
  }
131
132
  this.div.hidden = false;
132
133
  }
134
+ destroy() {
135
+ var _a;
136
+ (_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
137
+ }
133
138
  }
134
139
  _AnnotationEditorLayerBuilder_annotationLayer = new WeakMap(), _AnnotationEditorLayerBuilder_drawLayer = new WeakMap(), _AnnotationEditorLayerBuilder_onAppend = new WeakMap(), _AnnotationEditorLayerBuilder_textLayer = new WeakMap(), _AnnotationEditorLayerBuilder_uiManager = new WeakMap();
135
140
  export { AnnotationEditorLayerBuilder };
@@ -143,8 +143,8 @@ class AnnotationLayerBuilder {
143
143
  (_b = __classPrivateFieldGet(this, _AnnotationLayerBuilder_onAppend, "f")) === null || _b === void 0 ? void 0 : _b.call(this, div);
144
144
  this.annotationLayer = new AnnotationLayer({
145
145
  div,
146
- // accessibilityManager: this._accessibilityManager,
147
- accessibilityManager: null,
146
+ accessibilityManager: this._accessibilityManager,
147
+ // accessibilityManager: null,
148
148
  annotationCanvasMap: this._annotationCanvasMap,
149
149
  annotationEditorUIManager: this._annotationEditorUIManager,
150
150
  page: this.pdfPage,
@@ -190,6 +190,16 @@ class AnnotationLayerBuilder {
190
190
  var _a;
191
191
  return !!((_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.hasEditableAnnotations());
192
192
  }
193
+ destroy() {
194
+ var _a, _b, _c;
195
+ this.cancel();
196
+ (_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.destroy();
197
+ this.annotationLayer = null;
198
+ (_b = __classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f")) === null || _b === void 0 ? void 0 : _b.abort();
199
+ __classPrivateFieldSet(this, _AnnotationLayerBuilder_eventAbortController, null, "f");
200
+ (_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
201
+ this.div = null;
202
+ }
193
203
  }
194
204
  _AnnotationLayerBuilder_onAppend = new WeakMap(), _AnnotationLayerBuilder_eventAbortController = new WeakMap(), _AnnotationLayerBuilder_instances = new WeakSet(), _AnnotationLayerBuilder_updatePresentationModeState = function _AnnotationLayerBuilder_updatePresentationModeState(state) {
195
205
  if (!this.div) {
@@ -2766,6 +2766,12 @@ class AnnotationLayer {
2766
2766
  getEditableAnnotation(id) {
2767
2767
  return __classPrivateFieldGet(this, _AnnotationLayer_editableAnnotations, "f").get(id);
2768
2768
  }
2769
+ destroy() {
2770
+ var _a, _b;
2771
+ (_a = __classPrivateFieldGet(this, _AnnotationLayer_annotationCanvasMap, "f")) === null || _a === void 0 ? void 0 : _a.clear();
2772
+ (_b = this.div) === null || _b === void 0 ? void 0 : _b.remove();
2773
+ this.div = null;
2774
+ }
2769
2775
  }
2770
2776
  _AnnotationLayer_accessibilityManager = new WeakMap(), _AnnotationLayer_annotationCanvasMap = new WeakMap(), _AnnotationLayer_editableAnnotations = new WeakMap(), _AnnotationLayer_instances = new WeakSet(), _AnnotationLayer_appendElement = function _AnnotationLayer_appendElement(element, id) {
2771
2777
  var _a;
@@ -47,10 +47,11 @@ class DrawLayerBuilder {
47
47
  }
48
48
  cancel() {
49
49
  // this._cancelled = true;
50
+ var _a;
50
51
  if (!__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
51
52
  return;
52
53
  }
53
- __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f").destroy();
54
+ (_a = __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) === null || _a === void 0 ? void 0 : _a.destroy();
54
55
  __classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, null, "f");
55
56
  }
56
57
  setParent(parent) {
@@ -60,6 +61,9 @@ class DrawLayerBuilder {
60
61
  getDrawLayer() {
61
62
  return __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f");
62
63
  }
64
+ destroy() {
65
+ this.cancel();
66
+ }
63
67
  }
64
68
  _DrawLayerBuilder_drawLayer = new WeakMap();
65
69
  export { DrawLayerBuilder };
@@ -178,6 +178,11 @@ class TextAccessibilityManager {
178
178
  }
179
179
  return id;
180
180
  }
181
+ destroy() {
182
+ __classPrivateFieldSet(this, _TextAccessibilityManager_textNodes, new Map(), "f");
183
+ __classPrivateFieldSet(this, _TextAccessibilityManager_waitingElements, new Map(), "f");
184
+ __classPrivateFieldSet(this, _TextAccessibilityManager_textChildren, null, "f");
185
+ }
181
186
  }
182
187
  _a = TextAccessibilityManager, _TextAccessibilityManager_enabled = new WeakMap(), _TextAccessibilityManager_textChildren = new WeakMap(), _TextAccessibilityManager_textNodes = new WeakMap(), _TextAccessibilityManager_waitingElements = new WeakMap(), _TextAccessibilityManager_instances = new WeakSet(), _TextAccessibilityManager_compareElementPositions = function _TextAccessibilityManager_compareElementPositions(e1, e2) {
183
188
  const rect1 = e1.getBoundingClientRect();
@@ -124,13 +124,25 @@ class TextLayerBuilder {
124
124
  * Cancel rendering of the text layer.
125
125
  */
126
126
  cancel() {
127
- var _b, _c;
127
+ var _b, _c, _d;
128
128
  (_b = __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f")) === null || _b === void 0 ? void 0 : _b.cancel();
129
129
  __classPrivateFieldSet(this, _TextLayerBuilder_textLayer, null, "f");
130
130
  // this.highlighter?.disable();
131
131
  (_c = this.accessibilityManager) === null || _c === void 0 ? void 0 : _c.disable();
132
+ (_d = this.accessibilityManager) === null || _d === void 0 ? void 0 : _d.destroy();
132
133
  __classPrivateFieldGet(_a, _a, "m", _TextLayerBuilder_removeGlobalSelectionListener).call(_a, this.div);
133
134
  }
135
+ destroy() {
136
+ var _b, _c;
137
+ TextLayer.cleanup();
138
+ this.cancel();
139
+ this.pdfPage = null;
140
+ // this.highlighter = null;
141
+ (_b = this.accessibilityManager) === null || _b === void 0 ? void 0 : _b.destroy();
142
+ this.accessibilityManager = null;
143
+ (_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
144
+ this.div = null;
145
+ }
134
146
  }
135
147
  _a = TextLayerBuilder, _TextLayerBuilder_onAppend = new WeakMap(), _TextLayerBuilder_textLayer = new WeakMap(), _TextLayerBuilder_instances = new WeakSet(), _TextLayerBuilder_bindMouse = function _TextLayerBuilder_bindMouse(end) {
136
148
  const { div } = this;
@@ -482,3 +482,4 @@ const createCanvas = (page, zoom = 1, cssClass = '') => {
482
482
  styles
483
483
  };
484
484
  };
485
+ export const getDevicePixelRatio = () => (window === null || window === void 0 ? void 0 : window.devicePixelRatio) || 1;
@@ -96,9 +96,27 @@ export class Page extends Component {
96
96
  this.resetState();
97
97
  }
98
98
  destroy() {
99
+ var _a, _b, _c, _d, _e;
99
100
  this.destroyTextLayer();
101
+ if (this.canvas) {
102
+ this.canvas.width = 0;
103
+ this.canvas.height = 0;
104
+ this.canvas.remove();
105
+ this.canvas = null;
106
+ }
107
+ if (this.canvasForPrint) {
108
+ this.canvasForPrint.width = 0;
109
+ this.canvasForPrint.height = 0;
110
+ this.canvasForPrint.remove();
111
+ this.canvasForPrint = null;
112
+ }
113
+ (_a = this.drawLayer) === null || _a === void 0 ? void 0 : _a.destroy();
114
+ (_b = this.annotationLayer) === null || _b === void 0 ? void 0 : _b.destroy();
115
+ (_c = this.annotationEditorLayer) === null || _c === void 0 ? void 0 : _c.destroy();
116
+ (_d = this.div) === null || _d === void 0 ? void 0 : _d.remove();
100
117
  this.div = null;
101
118
  this.pdfViewer = null;
119
+ (_e = this.pdfPage) === null || _e === void 0 ? void 0 : _e.cleanup();
102
120
  this.pdfPage = null;
103
121
  }
104
122
  get isEditing() {
@@ -129,6 +147,9 @@ export class Page extends Component {
129
147
  return viewport;
130
148
  }
131
149
  destroyTextLayer() {
150
+ var _a, _b;
151
+ (_a = this.textLayer) === null || _a === void 0 ? void 0 : _a.cancel();
152
+ (_b = this.textLayer) === null || _b === void 0 ? void 0 : _b.destroy();
132
153
  this.removeTextLayer();
133
154
  this.textLayer = null;
134
155
  }
@@ -1,7 +1,7 @@
1
1
  var _PdfViewer_instances, _PdfViewer_annotationEditorMode, _PdfViewer_switchAnnotationEditorModeTimeoutId, _PdfViewer_annotationMode, _PdfViewer_eventAbortController, _PdfViewer_onPageRenderedCallback, _PdfViewer_switchToEditAnnotationMode, _PdfViewer_scrollIntoView;
2
2
  import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
3
  import { deepExtend, Component, isString, toArray, noop, hasValue, toClassSelector, addClass, removeClass, mousewheelDelta, convertToHtml, clamp, createPromise } from "../common/main";
4
- import { currentPage, parsePdfFromBase64String, scale as getRenderScale, adjustCanvasSize, createElement } from "../utils";
4
+ import { currentPage, parsePdfFromBase64String, adjustCanvasSize, createElement, getDevicePixelRatio } from "../utils";
5
5
  import { SearchService } from "../search";
6
6
  import { Scroller, throttle } from "../scroller";
7
7
  import { saveAs } from "@progress/kendo-file-saver";
@@ -61,6 +61,7 @@ export class PdfViewer extends Component {
61
61
  pageWheelThrottleDelay: 200,
62
62
  // ported from pdf.js
63
63
  printResolution: 100,
64
+ renderScale: 1.4,
64
65
  loadOnDemand: false,
65
66
  loadOnDemandPageSize: 2,
66
67
  messages: {
@@ -78,6 +79,7 @@ export class PdfViewer extends Component {
78
79
  },
79
80
  elementSelectors: {
80
81
  pageSelector: "k-page:not(.k-blank-page)",
82
+ anyPageSelector: "k-page",
81
83
  pagesContainerClass: "k-pdf-viewer-pages",
82
84
  pageCanvasWrapper: "k-canvas-wrapper",
83
85
  documentContainerClass: "k-pdf-viewer-canvas",
@@ -219,6 +221,7 @@ export class PdfViewer extends Component {
219
221
  return;
220
222
  }
221
223
  e.preventDefault();
224
+ e.stopPropagation();
222
225
  const wheelDelta = mousewheelDelta(e);
223
226
  const zoomModifier = wheelDelta < 0 ? 1 : -1;
224
227
  const zoomLevel = this.state.zoomLevel + (zoomModifier * this.options.zoomRate);
@@ -746,20 +749,15 @@ export class PdfViewer extends Component {
746
749
  if (zoom <= 0) {
747
750
  return;
748
751
  }
749
- const renderScale = getRenderScale();
752
+ const renderScale = this.options.renderScale * getDevicePixelRatio();
750
753
  let scaleNum = zoom * renderScale;
751
754
  if (printUnits) {
752
755
  scaleNum = zoom || renderScale;
753
756
  }
754
- // const scaleNum = zoom * renderScale;
755
757
  // changing the viewport dimensions here requires changes in
756
758
  // page.getPrintContentAsync for the printing dimensions
757
759
  const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
758
760
  const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
759
- // const styles = {
760
- // width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
761
- // height: Math.floor(viewport.height / scaleNum) * zoom + 'pt'
762
- // };
763
761
  // use PageView.setLayerDimensions
764
762
  const { pageWidth, pageHeight } = viewport.rawDims;
765
763
  const styles = {
@@ -1019,9 +1017,12 @@ export class PdfViewer extends Component {
1019
1017
  }
1020
1018
  calculateZoomLevel({ zoomLevel, zoomLevelType, currentZoom }) {
1021
1019
  const documentContainer = this.getDocumentContainer();
1022
- const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.pageSelector));
1023
- const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
1020
+ const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.anyPageSelector));
1024
1021
  let calculatedZoomLevel = clamp(zoomLevel || DEFAULT_ZOOM_LEVEL, this.options.minZoom, this.options.maxZoom);
1022
+ if (!hasValue(page)) {
1023
+ return calculatedZoomLevel;
1024
+ }
1025
+ const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
1025
1026
  if (zoomLevelType === "ActualWidth" || zoomLevelType === "actualWidth") {
1026
1027
  calculatedZoomLevel = 1;
1027
1028
  }
@@ -5,6 +5,7 @@
5
5
  /** @typedef {import("./interfaces").IL10n} IL10n */
6
6
  /** @typedef {import("../src/display/annotation_layer.js").AnnotationLayer} AnnotationLayer */
7
7
  import { AnnotationEditorLayer } from "./annotation-editor-layer";
8
+ import { TextAccessibilityManager } from "./helpers/text-accessibility-manager";
8
9
  /**
9
10
  * @typedef {Object} AnnotationEditorLayerBuilderOptions
10
11
  * @property {AnnotationEditorUIManager} [uiManager]
@@ -22,7 +23,7 @@ declare class AnnotationEditorLayerBuilder {
22
23
  annotationEditorLayer: AnnotationEditorLayer;
23
24
  _cancelled: any;
24
25
  div: any;
25
- accessibilityManager: any;
26
+ accessibilityManager: TextAccessibilityManager;
26
27
  /**
27
28
  * @param {AnnotationEditorLayerBuilderOptions} options
28
29
  */
@@ -35,5 +36,6 @@ declare class AnnotationEditorLayerBuilder {
35
36
  cancel(): void;
36
37
  hide(): void;
37
38
  show(): void;
39
+ destroy(): void;
38
40
  }
39
41
  export { AnnotationEditorLayerBuilder };
@@ -115,11 +115,12 @@ class AnnotationEditorLayerBuilder {
115
115
  });
116
116
  }
117
117
  cancel() {
118
+ var _a;
118
119
  this._cancelled = true;
119
120
  if (!this.div) {
120
121
  return;
121
122
  }
122
- this.annotationEditorLayer.destroy();
123
+ (_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
123
124
  }
124
125
  hide() {
125
126
  if (!this.div) {
@@ -133,6 +134,10 @@ class AnnotationEditorLayerBuilder {
133
134
  }
134
135
  this.div.hidden = false;
135
136
  }
137
+ destroy() {
138
+ var _a;
139
+ (_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
140
+ }
136
141
  }
137
142
  exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
138
143
  _AnnotationEditorLayerBuilder_annotationLayer = new WeakMap(), _AnnotationEditorLayerBuilder_drawLayer = new WeakMap(), _AnnotationEditorLayerBuilder_onAppend = new WeakMap(), _AnnotationEditorLayerBuilder_textLayer = new WeakMap(), _AnnotationEditorLayerBuilder_uiManager = new WeakMap();
@@ -1,5 +1,6 @@
1
1
  import { PDFLinkService } from "../links/link-service";
2
2
  import { AnnotationLayer } from "./annotation-layer";
3
+ import { TextAccessibilityManager } from "./helpers/text-accessibility-manager";
3
4
  import { EventBus } from "./shared/event_utils";
4
5
  /**
5
6
  * @typedef {Object} AnnotationLayerBuilderOptions
@@ -30,7 +31,7 @@ declare class AnnotationLayerBuilder {
30
31
  div: any;
31
32
  _cancelled: any;
32
33
  _eventBus: EventBus;
33
- _accessibilityManager: any;
34
+ _accessibilityManager: TextAccessibilityManager;
34
35
  renderForms: any;
35
36
  /**
36
37
  * @param {AnnotationLayerBuilderOptions} options
@@ -56,5 +57,6 @@ declare class AnnotationLayerBuilder {
56
57
  cancel(): void;
57
58
  hide(): void;
58
59
  hasEditableAnnotations(): boolean;
60
+ destroy(): void;
59
61
  }
60
62
  export { AnnotationLayerBuilder };
@@ -146,8 +146,8 @@ class AnnotationLayerBuilder {
146
146
  (_b = tslib_1.__classPrivateFieldGet(this, _AnnotationLayerBuilder_onAppend, "f")) === null || _b === void 0 ? void 0 : _b.call(this, div);
147
147
  this.annotationLayer = new annotation_layer_1.AnnotationLayer({
148
148
  div,
149
- // accessibilityManager: this._accessibilityManager,
150
- accessibilityManager: null,
149
+ accessibilityManager: this._accessibilityManager,
150
+ // accessibilityManager: null,
151
151
  annotationCanvasMap: this._annotationCanvasMap,
152
152
  annotationEditorUIManager: this._annotationEditorUIManager,
153
153
  page: this.pdfPage,
@@ -193,6 +193,16 @@ class AnnotationLayerBuilder {
193
193
  var _a;
194
194
  return !!((_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.hasEditableAnnotations());
195
195
  }
196
+ destroy() {
197
+ var _a, _b, _c;
198
+ this.cancel();
199
+ (_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.destroy();
200
+ this.annotationLayer = null;
201
+ (_b = tslib_1.__classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f")) === null || _b === void 0 ? void 0 : _b.abort();
202
+ tslib_1.__classPrivateFieldSet(this, _AnnotationLayerBuilder_eventAbortController, null, "f");
203
+ (_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
204
+ this.div = null;
205
+ }
196
206
  }
197
207
  exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
198
208
  _AnnotationLayerBuilder_onAppend = new WeakMap(), _AnnotationLayerBuilder_eventAbortController = new WeakMap(), _AnnotationLayerBuilder_instances = new WeakSet(), _AnnotationLayerBuilder_updatePresentationModeState = function _AnnotationLayerBuilder_updatePresentationModeState(state) {
@@ -1,3 +1,4 @@
1
+ import { AnnotationEditorUIManager } from "./annotation-editor-ui-manager";
1
2
  declare class AnnotationElement {
2
3
  #private;
3
4
  isRenderable: any;
@@ -101,7 +102,7 @@ declare class AnnotationLayer {
101
102
  page: any;
102
103
  viewport: any;
103
104
  zIndex: any;
104
- _annotationEditorUIManager: any;
105
+ _annotationEditorUIManager: AnnotationEditorUIManager;
105
106
  constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, viewport }: {
106
107
  div: any;
107
108
  accessibilityManager: any;
@@ -130,5 +131,6 @@ declare class AnnotationLayer {
130
131
  }): void;
131
132
  getEditableAnnotations(): any[];
132
133
  getEditableAnnotation(id: any): any;
134
+ destroy(): void;
133
135
  }
134
136
  export { AnnotationLayer, FreeTextAnnotationElement };
@@ -2770,6 +2770,12 @@ class AnnotationLayer {
2770
2770
  getEditableAnnotation(id) {
2771
2771
  return tslib_1.__classPrivateFieldGet(this, _AnnotationLayer_editableAnnotations, "f").get(id);
2772
2772
  }
2773
+ destroy() {
2774
+ var _a, _b;
2775
+ (_a = tslib_1.__classPrivateFieldGet(this, _AnnotationLayer_annotationCanvasMap, "f")) === null || _a === void 0 ? void 0 : _a.clear();
2776
+ (_b = this.div) === null || _b === void 0 ? void 0 : _b.remove();
2777
+ this.div = null;
2778
+ }
2773
2779
  }
2774
2780
  exports.AnnotationLayer = AnnotationLayer;
2775
2781
  _AnnotationLayer_accessibilityManager = new WeakMap(), _AnnotationLayer_annotationCanvasMap = new WeakMap(), _AnnotationLayer_editableAnnotations = new WeakMap(), _AnnotationLayer_instances = new WeakSet(), _AnnotationLayer_appendElement = function _AnnotationLayer_appendElement(element, id) {
@@ -1,3 +1,4 @@
1
+ import { DrawLayer } from "./draw-layer";
1
2
  /**
2
3
  * @typedef {Object} DrawLayerBuilderOptions
3
4
  * @property {number} pageIndex
@@ -16,6 +17,7 @@ declare class DrawLayerBuilder {
16
17
  render(intent?: string): Promise<void>;
17
18
  cancel(): void;
18
19
  setParent(parent: any): void;
19
- getDrawLayer(): any;
20
+ getDrawLayer(): DrawLayer;
21
+ destroy(): void;
20
22
  }
21
23
  export { DrawLayerBuilder };
@@ -50,10 +50,11 @@ class DrawLayerBuilder {
50
50
  }
51
51
  cancel() {
52
52
  // this._cancelled = true;
53
+ var _a;
53
54
  if (!tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
54
55
  return;
55
56
  }
56
- tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f").destroy();
57
+ (_a = tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) === null || _a === void 0 ? void 0 : _a.destroy();
57
58
  tslib_1.__classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, null, "f");
58
59
  }
59
60
  setParent(parent) {
@@ -63,6 +64,9 @@ class DrawLayerBuilder {
63
64
  getDrawLayer() {
64
65
  return tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f");
65
66
  }
67
+ destroy() {
68
+ this.cancel();
69
+ }
66
70
  }
67
71
  exports.DrawLayerBuilder = DrawLayerBuilder;
68
72
  _DrawLayerBuilder_drawLayer = new WeakMap();
@@ -32,5 +32,6 @@ declare class TextAccessibilityManager {
32
32
  * @returns {string|null} The id in the struct tree if any.
33
33
  */
34
34
  moveElementInDOM(container: any, element: any, contentElement: any, isRemovable: any): any;
35
+ destroy(): void;
35
36
  }
36
37
  export { TextAccessibilityManager };
@@ -181,6 +181,11 @@ class TextAccessibilityManager {
181
181
  }
182
182
  return id;
183
183
  }
184
+ destroy() {
185
+ tslib_1.__classPrivateFieldSet(this, _TextAccessibilityManager_textNodes, new Map(), "f");
186
+ tslib_1.__classPrivateFieldSet(this, _TextAccessibilityManager_waitingElements, new Map(), "f");
187
+ tslib_1.__classPrivateFieldSet(this, _TextAccessibilityManager_textChildren, null, "f");
188
+ }
184
189
  }
185
190
  exports.TextAccessibilityManager = TextAccessibilityManager;
186
191
  _a = TextAccessibilityManager, _TextAccessibilityManager_enabled = new WeakMap(), _TextAccessibilityManager_textChildren = new WeakMap(), _TextAccessibilityManager_textNodes = new WeakMap(), _TextAccessibilityManager_waitingElements = new WeakMap(), _TextAccessibilityManager_instances = new WeakSet(), _TextAccessibilityManager_compareElementPositions = function _TextAccessibilityManager_compareElementPositions(e1, e2) {
@@ -1,3 +1,4 @@
1
+ import { TextAccessibilityManager } from "../annotations/helpers/text-accessibility-manager";
1
2
  /**
2
3
  * The text layer builder provides text selection functionality for the PDF.
3
4
  * It does this by creating overlay divs over the PDF's text. These divs
@@ -7,7 +8,7 @@ declare class TextLayerBuilder {
7
8
  #private;
8
9
  pdfPage: any;
9
10
  div: any;
10
- accessibilityManager: any;
11
+ accessibilityManager: TextAccessibilityManager;
11
12
  constructor({ pdfPage, accessibilityManager, styles, onAppend }: {
12
13
  pdfPage: any;
13
14
  accessibilityManager: any;
@@ -26,5 +27,6 @@ declare class TextLayerBuilder {
26
27
  * Cancel rendering of the text layer.
27
28
  */
28
29
  cancel(): void;
30
+ destroy(): void;
29
31
  }
30
32
  export { TextLayerBuilder };
@@ -127,13 +127,25 @@ class TextLayerBuilder {
127
127
  * Cancel rendering of the text layer.
128
128
  */
129
129
  cancel() {
130
- var _b, _c;
130
+ var _b, _c, _d;
131
131
  (_b = tslib_1.__classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f")) === null || _b === void 0 ? void 0 : _b.cancel();
132
132
  tslib_1.__classPrivateFieldSet(this, _TextLayerBuilder_textLayer, null, "f");
133
133
  // this.highlighter?.disable();
134
134
  (_c = this.accessibilityManager) === null || _c === void 0 ? void 0 : _c.disable();
135
+ (_d = this.accessibilityManager) === null || _d === void 0 ? void 0 : _d.destroy();
135
136
  tslib_1.__classPrivateFieldGet(_a, _a, "m", _TextLayerBuilder_removeGlobalSelectionListener).call(_a, this.div);
136
137
  }
138
+ destroy() {
139
+ var _b, _c;
140
+ pdf_mjs_1.TextLayer.cleanup();
141
+ this.cancel();
142
+ this.pdfPage = null;
143
+ // this.highlighter = null;
144
+ (_b = this.accessibilityManager) === null || _b === void 0 ? void 0 : _b.destroy();
145
+ this.accessibilityManager = null;
146
+ (_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
147
+ this.div = null;
148
+ }
137
149
  }
138
150
  exports.TextLayerBuilder = TextLayerBuilder;
139
151
  _a = TextLayerBuilder, _TextLayerBuilder_onAppend = new WeakMap(), _TextLayerBuilder_textLayer = new WeakMap(), _TextLayerBuilder_instances = new WeakSet(), _TextLayerBuilder_bindMouse = function _TextLayerBuilder_bindMouse(end) {
@@ -121,3 +121,4 @@ export declare const adjustCanvasSize: (targetWidth: number, targetHeight: numbe
121
121
  adjustedHeight: number;
122
122
  adjustRatio: number;
123
123
  };
124
+ export declare const getDevicePixelRatio: () => number;
package/dist/npm/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.adjustCanvasSize = exports.currentPage = exports.scrollToPage = exports.calculateZoomLevel = exports.goToPreviousSearchMatch = exports.goToNextSearchMatch = exports.renderPage = exports.transforms = exports.createElement = exports.print = exports.reloadDocument = exports.loadPDF = exports.download = exports.removeChildren = exports.parsePdfFromBase64String = exports.scale = exports.DEFAULT_ZOOM_LEVEL = void 0;
3
+ exports.getDevicePixelRatio = exports.adjustCanvasSize = exports.currentPage = exports.scrollToPage = exports.calculateZoomLevel = exports.goToPreviousSearchMatch = exports.goToNextSearchMatch = exports.renderPage = exports.transforms = exports.createElement = exports.print = exports.reloadDocument = exports.loadPDF = exports.download = exports.removeChildren = exports.parsePdfFromBase64String = exports.scale = exports.DEFAULT_ZOOM_LEVEL = void 0;
4
4
  const kendo_file_saver_1 = require("@progress/kendo-file-saver");
5
5
  const kendo_common_1 = require("@progress/kendo-common");
6
6
  const pdf_mjs_1 = require("pdfjs-dist/legacy/build/pdf.mjs");
@@ -500,3 +500,5 @@ const createCanvas = (page, zoom = 1, cssClass = '') => {
500
500
  styles
501
501
  };
502
502
  };
503
+ const getDevicePixelRatio = () => (window === null || window === void 0 ? void 0 : window.devicePixelRatio) || 1;
504
+ exports.getDevicePixelRatio = getDevicePixelRatio;
@@ -96,9 +96,27 @@ class Page extends component_1.Component {
96
96
  this.resetState();
97
97
  }
98
98
  destroy() {
99
+ var _a, _b, _c, _d, _e;
99
100
  this.destroyTextLayer();
101
+ if (this.canvas) {
102
+ this.canvas.width = 0;
103
+ this.canvas.height = 0;
104
+ this.canvas.remove();
105
+ this.canvas = null;
106
+ }
107
+ if (this.canvasForPrint) {
108
+ this.canvasForPrint.width = 0;
109
+ this.canvasForPrint.height = 0;
110
+ this.canvasForPrint.remove();
111
+ this.canvasForPrint = null;
112
+ }
113
+ (_a = this.drawLayer) === null || _a === void 0 ? void 0 : _a.destroy();
114
+ (_b = this.annotationLayer) === null || _b === void 0 ? void 0 : _b.destroy();
115
+ (_c = this.annotationEditorLayer) === null || _c === void 0 ? void 0 : _c.destroy();
116
+ (_d = this.div) === null || _d === void 0 ? void 0 : _d.remove();
100
117
  this.div = null;
101
118
  this.pdfViewer = null;
119
+ (_e = this.pdfPage) === null || _e === void 0 ? void 0 : _e.cleanup();
102
120
  this.pdfPage = null;
103
121
  }
104
122
  get isEditing() {
@@ -129,6 +147,9 @@ class Page extends component_1.Component {
129
147
  return viewport;
130
148
  }
131
149
  destroyTextLayer() {
150
+ var _a, _b;
151
+ (_a = this.textLayer) === null || _a === void 0 ? void 0 : _a.cancel();
152
+ (_b = this.textLayer) === null || _b === void 0 ? void 0 : _b.destroy();
132
153
  this.removeTextLayer();
133
154
  this.textLayer = null;
134
155
  }
@@ -64,6 +64,7 @@ class PdfViewer extends main_1.Component {
64
64
  pageWheelThrottleDelay: 200,
65
65
  // ported from pdf.js
66
66
  printResolution: 100,
67
+ renderScale: 1.4,
67
68
  loadOnDemand: false,
68
69
  loadOnDemandPageSize: 2,
69
70
  messages: {
@@ -81,6 +82,7 @@ class PdfViewer extends main_1.Component {
81
82
  },
82
83
  elementSelectors: {
83
84
  pageSelector: "k-page:not(.k-blank-page)",
85
+ anyPageSelector: "k-page",
84
86
  pagesContainerClass: "k-pdf-viewer-pages",
85
87
  pageCanvasWrapper: "k-canvas-wrapper",
86
88
  documentContainerClass: "k-pdf-viewer-canvas",
@@ -222,6 +224,7 @@ class PdfViewer extends main_1.Component {
222
224
  return;
223
225
  }
224
226
  e.preventDefault();
227
+ e.stopPropagation();
225
228
  const wheelDelta = (0, main_1.mousewheelDelta)(e);
226
229
  const zoomModifier = wheelDelta < 0 ? 1 : -1;
227
230
  const zoomLevel = this.state.zoomLevel + (zoomModifier * this.options.zoomRate);
@@ -749,20 +752,15 @@ class PdfViewer extends main_1.Component {
749
752
  if (zoom <= 0) {
750
753
  return;
751
754
  }
752
- const renderScale = (0, utils_1.scale)();
755
+ const renderScale = this.options.renderScale * (0, utils_1.getDevicePixelRatio)();
753
756
  let scaleNum = zoom * renderScale;
754
757
  if (printUnits) {
755
758
  scaleNum = zoom || renderScale;
756
759
  }
757
- // const scaleNum = zoom * renderScale;
758
760
  // changing the viewport dimensions here requires changes in
759
761
  // page.getPrintContentAsync for the printing dimensions
760
762
  const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
761
763
  const { adjustedWidth, adjustedHeight, adjustRatio } = (0, utils_1.adjustCanvasSize)(viewport.width, viewport.height);
762
- // const styles = {
763
- // width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
764
- // height: Math.floor(viewport.height / scaleNum) * zoom + 'pt'
765
- // };
766
764
  // use PageView.setLayerDimensions
767
765
  const { pageWidth, pageHeight } = viewport.rawDims;
768
766
  const styles = {
@@ -1022,9 +1020,12 @@ class PdfViewer extends main_1.Component {
1022
1020
  }
1023
1021
  calculateZoomLevel({ zoomLevel, zoomLevelType, currentZoom }) {
1024
1022
  const documentContainer = this.getDocumentContainer();
1025
- const page = documentContainer.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.pageSelector));
1026
- const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
1023
+ const page = documentContainer.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.anyPageSelector));
1027
1024
  let calculatedZoomLevel = (0, main_1.clamp)(zoomLevel || DEFAULT_ZOOM_LEVEL, this.options.minZoom, this.options.maxZoom);
1025
+ if (!(0, main_1.hasValue)(page)) {
1026
+ return calculatedZoomLevel;
1027
+ }
1028
+ const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
1028
1029
  if (zoomLevelType === "ActualWidth" || zoomLevelType === "actualWidth") {
1029
1030
  calculatedZoomLevel = 1;
1030
1031
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-pdfviewer-common",
3
3
  "description": "Kendo UI TypeScript package exporting functions for PDFViewer component",
4
- "version": "0.5.0-develop.1",
4
+ "version": "0.5.0-develop.3",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],