@progress/kendo-pdfviewer-common 0.5.0-develop.2 → 0.5.0-develop.4
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/dist/es/widget/page.js
CHANGED
|
@@ -163,10 +163,9 @@ export class Page extends Component {
|
|
|
163
163
|
const canvas = this.canvasForPrint;
|
|
164
164
|
const printContentLoadPromise = this.createPromise();
|
|
165
165
|
const printContent = new Image();
|
|
166
|
-
const printUnits = this.pdfViewer.getPrintUnits();
|
|
167
166
|
const viewportRawDimensions = this.viewport.rawDims;
|
|
168
|
-
const pageHeight = Math.floor(viewportRawDimensions.pageHeight
|
|
169
|
-
const pageWidth = Math.floor(viewportRawDimensions.pageWidth
|
|
167
|
+
const pageHeight = Math.floor(viewportRawDimensions.pageHeight);
|
|
168
|
+
const pageWidth = Math.floor(viewportRawDimensions.pageWidth);
|
|
170
169
|
printContent.src = canvas.toDataURL();
|
|
171
170
|
printContent.width = pageWidth;
|
|
172
171
|
printContent.height = pageHeight;
|
|
@@ -61,7 +61,8 @@ export class PdfViewer extends Component {
|
|
|
61
61
|
pageWheelThrottleDelay: 200,
|
|
62
62
|
// ported from pdf.js
|
|
63
63
|
printResolution: 100,
|
|
64
|
-
|
|
64
|
+
// the render scale that is used for controlling the render quality
|
|
65
|
+
renderScale: 3,
|
|
65
66
|
loadOnDemand: false,
|
|
66
67
|
loadOnDemandPageSize: 2,
|
|
67
68
|
messages: {
|
|
@@ -79,6 +80,7 @@ export class PdfViewer extends Component {
|
|
|
79
80
|
},
|
|
80
81
|
elementSelectors: {
|
|
81
82
|
pageSelector: "k-page:not(.k-blank-page)",
|
|
83
|
+
anyPageSelector: "k-page",
|
|
82
84
|
pagesContainerClass: "k-pdf-viewer-pages",
|
|
83
85
|
pageCanvasWrapper: "k-canvas-wrapper",
|
|
84
86
|
documentContainerClass: "k-pdf-viewer-canvas",
|
|
@@ -253,6 +255,7 @@ export class PdfViewer extends Component {
|
|
|
253
255
|
destroy() {
|
|
254
256
|
this.destroyEventBus();
|
|
255
257
|
this.unbindEvents();
|
|
258
|
+
this.clearDocument();
|
|
256
259
|
this.destroySearchService();
|
|
257
260
|
this.destroyAnnotationEditorUIManager();
|
|
258
261
|
this.destroyDocumentScroller();
|
|
@@ -429,6 +432,7 @@ export class PdfViewer extends Component {
|
|
|
429
432
|
destroyAnnotationEditorUIManager() {
|
|
430
433
|
var _a;
|
|
431
434
|
(_a = this.annotationEditorUIManager) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
435
|
+
this.annotationEditorUIManager = null;
|
|
432
436
|
}
|
|
433
437
|
bindEventBusAnnotationsEvents() {
|
|
434
438
|
const eventBus = this.eventBus = this.eventBus || new EventBus();
|
|
@@ -748,22 +752,21 @@ export class PdfViewer extends Component {
|
|
|
748
752
|
if (zoom <= 0) {
|
|
749
753
|
return;
|
|
750
754
|
}
|
|
751
|
-
|
|
752
|
-
let scaleNum = zoom * renderScale;
|
|
755
|
+
let scaleNum = this.options.renderScale * getDevicePixelRatio();
|
|
753
756
|
if (printUnits) {
|
|
754
|
-
scaleNum = zoom ||
|
|
757
|
+
scaleNum = zoom || scaleNum;
|
|
755
758
|
}
|
|
756
759
|
// changing the viewport dimensions here requires changes in
|
|
757
760
|
// page.getPrintContentAsync for the printing dimensions
|
|
758
761
|
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
759
762
|
const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
|
|
760
|
-
// use PageView.setLayerDimensions
|
|
761
|
-
const { pageWidth, pageHeight } = viewport.rawDims;
|
|
762
763
|
const styles = {
|
|
763
764
|
// "round" is supported in all browsers since May 2024
|
|
764
765
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/round#browser_compatibility
|
|
765
|
-
width: `round(var(--scale-factor) * ${pageWidth}px, 1px)`,
|
|
766
|
-
height: `round(var(--scale-factor) * ${pageHeight}px, 1px)`
|
|
766
|
+
// width: `round(var(--scale-factor) * ${pageWidth}px, 1px)`,
|
|
767
|
+
// height: `round(var(--scale-factor) * ${pageHeight}px, 1px)`
|
|
768
|
+
width: `round(var(--scale-factor) * ${viewport.width / scaleNum}px, 1px)`,
|
|
769
|
+
height: `round(var(--scale-factor) * ${viewport.height / scaleNum}px, 1px)`
|
|
767
770
|
};
|
|
768
771
|
const pageElement = createElement("div", "k-page", styles);
|
|
769
772
|
const canvas = createElement("canvas", '', {
|
|
@@ -1016,9 +1019,12 @@ export class PdfViewer extends Component {
|
|
|
1016
1019
|
}
|
|
1017
1020
|
calculateZoomLevel({ zoomLevel, zoomLevelType, currentZoom }) {
|
|
1018
1021
|
const documentContainer = this.getDocumentContainer();
|
|
1019
|
-
const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.
|
|
1020
|
-
const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
|
|
1022
|
+
const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.anyPageSelector));
|
|
1021
1023
|
let calculatedZoomLevel = clamp(zoomLevel || DEFAULT_ZOOM_LEVEL, this.options.minZoom, this.options.maxZoom);
|
|
1024
|
+
if (!hasValue(page)) {
|
|
1025
|
+
return calculatedZoomLevel;
|
|
1026
|
+
}
|
|
1027
|
+
const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
|
|
1022
1028
|
if (zoomLevelType === "ActualWidth" || zoomLevelType === "actualWidth") {
|
|
1023
1029
|
calculatedZoomLevel = 1;
|
|
1024
1030
|
}
|
|
@@ -163,10 +163,9 @@ export class Page extends Component {
|
|
|
163
163
|
const canvas = this.canvasForPrint;
|
|
164
164
|
const printContentLoadPromise = this.createPromise();
|
|
165
165
|
const printContent = new Image();
|
|
166
|
-
const printUnits = this.pdfViewer.getPrintUnits();
|
|
167
166
|
const viewportRawDimensions = this.viewport.rawDims;
|
|
168
|
-
const pageHeight = Math.floor(viewportRawDimensions.pageHeight
|
|
169
|
-
const pageWidth = Math.floor(viewportRawDimensions.pageWidth
|
|
167
|
+
const pageHeight = Math.floor(viewportRawDimensions.pageHeight);
|
|
168
|
+
const pageWidth = Math.floor(viewportRawDimensions.pageWidth);
|
|
170
169
|
printContent.src = canvas.toDataURL();
|
|
171
170
|
printContent.width = pageWidth;
|
|
172
171
|
printContent.height = pageHeight;
|
|
@@ -61,7 +61,8 @@ export class PdfViewer extends Component {
|
|
|
61
61
|
pageWheelThrottleDelay: 200,
|
|
62
62
|
// ported from pdf.js
|
|
63
63
|
printResolution: 100,
|
|
64
|
-
|
|
64
|
+
// the render scale that is used for controlling the render quality
|
|
65
|
+
renderScale: 3,
|
|
65
66
|
loadOnDemand: false,
|
|
66
67
|
loadOnDemandPageSize: 2,
|
|
67
68
|
messages: {
|
|
@@ -79,6 +80,7 @@ export class PdfViewer extends Component {
|
|
|
79
80
|
},
|
|
80
81
|
elementSelectors: {
|
|
81
82
|
pageSelector: "k-page:not(.k-blank-page)",
|
|
83
|
+
anyPageSelector: "k-page",
|
|
82
84
|
pagesContainerClass: "k-pdf-viewer-pages",
|
|
83
85
|
pageCanvasWrapper: "k-canvas-wrapper",
|
|
84
86
|
documentContainerClass: "k-pdf-viewer-canvas",
|
|
@@ -253,6 +255,7 @@ export class PdfViewer extends Component {
|
|
|
253
255
|
destroy() {
|
|
254
256
|
this.destroyEventBus();
|
|
255
257
|
this.unbindEvents();
|
|
258
|
+
this.clearDocument();
|
|
256
259
|
this.destroySearchService();
|
|
257
260
|
this.destroyAnnotationEditorUIManager();
|
|
258
261
|
this.destroyDocumentScroller();
|
|
@@ -429,6 +432,7 @@ export class PdfViewer extends Component {
|
|
|
429
432
|
destroyAnnotationEditorUIManager() {
|
|
430
433
|
var _a;
|
|
431
434
|
(_a = this.annotationEditorUIManager) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
435
|
+
this.annotationEditorUIManager = null;
|
|
432
436
|
}
|
|
433
437
|
bindEventBusAnnotationsEvents() {
|
|
434
438
|
const eventBus = this.eventBus = this.eventBus || new EventBus();
|
|
@@ -748,22 +752,21 @@ export class PdfViewer extends Component {
|
|
|
748
752
|
if (zoom <= 0) {
|
|
749
753
|
return;
|
|
750
754
|
}
|
|
751
|
-
|
|
752
|
-
let scaleNum = zoom * renderScale;
|
|
755
|
+
let scaleNum = this.options.renderScale * getDevicePixelRatio();
|
|
753
756
|
if (printUnits) {
|
|
754
|
-
scaleNum = zoom ||
|
|
757
|
+
scaleNum = zoom || scaleNum;
|
|
755
758
|
}
|
|
756
759
|
// changing the viewport dimensions here requires changes in
|
|
757
760
|
// page.getPrintContentAsync for the printing dimensions
|
|
758
761
|
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
759
762
|
const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
|
|
760
|
-
// use PageView.setLayerDimensions
|
|
761
|
-
const { pageWidth, pageHeight } = viewport.rawDims;
|
|
762
763
|
const styles = {
|
|
763
764
|
// "round" is supported in all browsers since May 2024
|
|
764
765
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/round#browser_compatibility
|
|
765
|
-
width: `round(var(--scale-factor) * ${pageWidth}px, 1px)`,
|
|
766
|
-
height: `round(var(--scale-factor) * ${pageHeight}px, 1px)`
|
|
766
|
+
// width: `round(var(--scale-factor) * ${pageWidth}px, 1px)`,
|
|
767
|
+
// height: `round(var(--scale-factor) * ${pageHeight}px, 1px)`
|
|
768
|
+
width: `round(var(--scale-factor) * ${viewport.width / scaleNum}px, 1px)`,
|
|
769
|
+
height: `round(var(--scale-factor) * ${viewport.height / scaleNum}px, 1px)`
|
|
767
770
|
};
|
|
768
771
|
const pageElement = createElement("div", "k-page", styles);
|
|
769
772
|
const canvas = createElement("canvas", '', {
|
|
@@ -1016,9 +1019,12 @@ export class PdfViewer extends Component {
|
|
|
1016
1019
|
}
|
|
1017
1020
|
calculateZoomLevel({ zoomLevel, zoomLevelType, currentZoom }) {
|
|
1018
1021
|
const documentContainer = this.getDocumentContainer();
|
|
1019
|
-
const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.
|
|
1020
|
-
const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
|
|
1022
|
+
const page = documentContainer.querySelector(toClassSelector(this.options.elementSelectors.anyPageSelector));
|
|
1021
1023
|
let calculatedZoomLevel = clamp(zoomLevel || DEFAULT_ZOOM_LEVEL, this.options.minZoom, this.options.maxZoom);
|
|
1024
|
+
if (!hasValue(page)) {
|
|
1025
|
+
return calculatedZoomLevel;
|
|
1026
|
+
}
|
|
1027
|
+
const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
|
|
1022
1028
|
if (zoomLevelType === "ActualWidth" || zoomLevelType === "actualWidth") {
|
|
1023
1029
|
calculatedZoomLevel = 1;
|
|
1024
1030
|
}
|
package/dist/npm/widget/page.js
CHANGED
|
@@ -163,10 +163,9 @@ class Page extends component_1.Component {
|
|
|
163
163
|
const canvas = this.canvasForPrint;
|
|
164
164
|
const printContentLoadPromise = this.createPromise();
|
|
165
165
|
const printContent = new Image();
|
|
166
|
-
const printUnits = this.pdfViewer.getPrintUnits();
|
|
167
166
|
const viewportRawDimensions = this.viewport.rawDims;
|
|
168
|
-
const pageHeight = Math.floor(viewportRawDimensions.pageHeight
|
|
169
|
-
const pageWidth = Math.floor(viewportRawDimensions.pageWidth
|
|
167
|
+
const pageHeight = Math.floor(viewportRawDimensions.pageHeight);
|
|
168
|
+
const pageWidth = Math.floor(viewportRawDimensions.pageWidth);
|
|
170
169
|
printContent.src = canvas.toDataURL();
|
|
171
170
|
printContent.width = pageWidth;
|
|
172
171
|
printContent.height = pageHeight;
|
|
@@ -64,7 +64,8 @@ class PdfViewer extends main_1.Component {
|
|
|
64
64
|
pageWheelThrottleDelay: 200,
|
|
65
65
|
// ported from pdf.js
|
|
66
66
|
printResolution: 100,
|
|
67
|
-
|
|
67
|
+
// the render scale that is used for controlling the render quality
|
|
68
|
+
renderScale: 3,
|
|
68
69
|
loadOnDemand: false,
|
|
69
70
|
loadOnDemandPageSize: 2,
|
|
70
71
|
messages: {
|
|
@@ -82,6 +83,7 @@ class PdfViewer extends main_1.Component {
|
|
|
82
83
|
},
|
|
83
84
|
elementSelectors: {
|
|
84
85
|
pageSelector: "k-page:not(.k-blank-page)",
|
|
86
|
+
anyPageSelector: "k-page",
|
|
85
87
|
pagesContainerClass: "k-pdf-viewer-pages",
|
|
86
88
|
pageCanvasWrapper: "k-canvas-wrapper",
|
|
87
89
|
documentContainerClass: "k-pdf-viewer-canvas",
|
|
@@ -256,6 +258,7 @@ class PdfViewer extends main_1.Component {
|
|
|
256
258
|
destroy() {
|
|
257
259
|
this.destroyEventBus();
|
|
258
260
|
this.unbindEvents();
|
|
261
|
+
this.clearDocument();
|
|
259
262
|
this.destroySearchService();
|
|
260
263
|
this.destroyAnnotationEditorUIManager();
|
|
261
264
|
this.destroyDocumentScroller();
|
|
@@ -432,6 +435,7 @@ class PdfViewer extends main_1.Component {
|
|
|
432
435
|
destroyAnnotationEditorUIManager() {
|
|
433
436
|
var _a;
|
|
434
437
|
(_a = this.annotationEditorUIManager) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
438
|
+
this.annotationEditorUIManager = null;
|
|
435
439
|
}
|
|
436
440
|
bindEventBusAnnotationsEvents() {
|
|
437
441
|
const eventBus = this.eventBus = this.eventBus || new event_utils_1.EventBus();
|
|
@@ -751,22 +755,21 @@ class PdfViewer extends main_1.Component {
|
|
|
751
755
|
if (zoom <= 0) {
|
|
752
756
|
return;
|
|
753
757
|
}
|
|
754
|
-
|
|
755
|
-
let scaleNum = zoom * renderScale;
|
|
758
|
+
let scaleNum = this.options.renderScale * (0, utils_1.getDevicePixelRatio)();
|
|
756
759
|
if (printUnits) {
|
|
757
|
-
scaleNum = zoom ||
|
|
760
|
+
scaleNum = zoom || scaleNum;
|
|
758
761
|
}
|
|
759
762
|
// changing the viewport dimensions here requires changes in
|
|
760
763
|
// page.getPrintContentAsync for the printing dimensions
|
|
761
764
|
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
762
765
|
const { adjustedWidth, adjustedHeight, adjustRatio } = (0, utils_1.adjustCanvasSize)(viewport.width, viewport.height);
|
|
763
|
-
// use PageView.setLayerDimensions
|
|
764
|
-
const { pageWidth, pageHeight } = viewport.rawDims;
|
|
765
766
|
const styles = {
|
|
766
767
|
// "round" is supported in all browsers since May 2024
|
|
767
768
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/round#browser_compatibility
|
|
768
|
-
width: `round(var(--scale-factor) * ${pageWidth}px, 1px)`,
|
|
769
|
-
height: `round(var(--scale-factor) * ${pageHeight}px, 1px)`
|
|
769
|
+
// width: `round(var(--scale-factor) * ${pageWidth}px, 1px)`,
|
|
770
|
+
// height: `round(var(--scale-factor) * ${pageHeight}px, 1px)`
|
|
771
|
+
width: `round(var(--scale-factor) * ${viewport.width / scaleNum}px, 1px)`,
|
|
772
|
+
height: `round(var(--scale-factor) * ${viewport.height / scaleNum}px, 1px)`
|
|
770
773
|
};
|
|
771
774
|
const pageElement = (0, utils_1.createElement)("div", "k-page", styles);
|
|
772
775
|
const canvas = (0, utils_1.createElement)("canvas", '', {
|
|
@@ -1019,9 +1022,12 @@ class PdfViewer extends main_1.Component {
|
|
|
1019
1022
|
}
|
|
1020
1023
|
calculateZoomLevel({ zoomLevel, zoomLevelType, currentZoom }) {
|
|
1021
1024
|
const documentContainer = this.getDocumentContainer();
|
|
1022
|
-
const page = documentContainer.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.
|
|
1023
|
-
const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
|
|
1025
|
+
const page = documentContainer.querySelector((0, main_1.toClassSelector)(this.options.elementSelectors.anyPageSelector));
|
|
1024
1026
|
let calculatedZoomLevel = (0, main_1.clamp)(zoomLevel || DEFAULT_ZOOM_LEVEL, this.options.minZoom, this.options.maxZoom);
|
|
1027
|
+
if (!(0, main_1.hasValue)(page)) {
|
|
1028
|
+
return calculatedZoomLevel;
|
|
1029
|
+
}
|
|
1030
|
+
const pageSize = { width: page.offsetWidth, height: page.offsetHeight };
|
|
1025
1031
|
if (zoomLevelType === "ActualWidth" || zoomLevelType === "actualWidth") {
|
|
1026
1032
|
calculatedZoomLevel = 1;
|
|
1027
1033
|
}
|
package/package.json
CHANGED