@progress/kendo-pdfviewer-common 0.6.5-develop.1 → 1.0.0-develop.1
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/annotations/annotation-editor-ui-manager.js +1 -1
- package/dist/es/annotations/annotation-layer.js +2 -7
- package/dist/es/annotations/editors/free-text-editor.js +0 -1
- package/dist/es/annotations/editors/highlight-editor.js +2 -3
- package/dist/es/annotations/editors/outliner.js +2 -3
- package/dist/es/annotations.js +1 -1
- package/dist/es/common/component.js +1 -0
- package/dist/es/common/core.js +1 -2
- package/dist/es/common/dom.js +26 -0
- package/dist/es/types/index.js +1 -0
- package/dist/es/utils.js +5 -29
- package/dist/es/widget/page.js +1 -0
- package/dist/es/widget/pdfviewer.js +3 -0
- package/dist/es2015/annotations/annotation-editor-ui-manager.js +1 -1
- package/dist/es2015/annotations/annotation-layer.js +2 -7
- package/dist/es2015/annotations/editors/free-text-editor.js +0 -1
- package/dist/es2015/annotations/editors/highlight-editor.js +2 -3
- package/dist/es2015/annotations/editors/outliner.js +2 -3
- package/dist/es2015/annotations.js +1 -1
- package/dist/es2015/common/component.js +1 -0
- package/dist/es2015/common/core.js +1 -2
- package/dist/es2015/common/dom.js +26 -0
- package/dist/es2015/types/index.js +1 -0
- package/dist/es2015/utils.js +5 -29
- package/dist/es2015/widget/page.js +1 -0
- package/dist/es2015/widget/pdfviewer.js +3 -0
- package/dist/npm/annotations/annotation-editor-ui-manager.js +1 -1
- package/dist/npm/annotations/annotation-layer.js +2 -7
- package/dist/npm/annotations/editors/free-text-editor.js +0 -1
- package/dist/npm/annotations/editors/highlight-editor.js +2 -3
- package/dist/npm/annotations/editors/outliner.js +2 -3
- package/dist/npm/annotations.js +4 -4
- package/dist/npm/common/component.d.ts +1 -0
- package/dist/npm/common/component.js +1 -0
- package/dist/npm/common/core.js +1 -2
- package/dist/npm/common/dom.d.ts +10 -0
- package/dist/npm/common/dom.js +29 -1
- package/dist/npm/main.d.ts +2 -2
- package/dist/npm/types/index.d.ts +1 -0
- package/dist/npm/types/index.js +2 -0
- package/dist/npm/utils.d.ts +2 -10
- package/dist/npm/utils.js +12 -37
- package/dist/npm/widget/page.js +1 -0
- package/dist/npm/widget/pdfviewer.js +3 -0
- package/package.json +27 -35
|
@@ -869,7 +869,7 @@ export class AnnotationEditorUIManager {
|
|
|
869
869
|
case AnnotationEditorParamsType.CREATE:
|
|
870
870
|
this.currentLayer.addNewEditor();
|
|
871
871
|
return;
|
|
872
|
-
case AnnotationEditorParamsType.
|
|
872
|
+
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
873
873
|
// this.#mainHighlightColorPicker?.updateColor(value);
|
|
874
874
|
break;
|
|
875
875
|
case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
|
|
@@ -1917,9 +1917,7 @@ class PopupElement {
|
|
|
1917
1917
|
const popup = (__classPrivateFieldSet(this, _PopupElement_popup, document.createElement("div"), "f"));
|
|
1918
1918
|
popup.className = "popup";
|
|
1919
1919
|
if (__classPrivateFieldGet(this, _PopupElement_color, "f")) {
|
|
1920
|
-
const baseColor = (popup.style.outlineColor = Util.makeHexColor(
|
|
1921
|
-
// @ts-expect-error TS(2556):
|
|
1922
|
-
...__classPrivateFieldGet(this, _PopupElement_color, "f")));
|
|
1920
|
+
const baseColor = (popup.style.outlineColor = Util.makeHexColor(...__classPrivateFieldGet(this, _PopupElement_color, "f")));
|
|
1923
1921
|
if (
|
|
1924
1922
|
// (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
|
1925
1923
|
CSS.supports("background-color", "color-mix(in srgb, red 30%, white)")) {
|
|
@@ -1931,9 +1929,7 @@ class PopupElement {
|
|
|
1931
1929
|
// TODO: Use color-mix when it's supported everywhere.
|
|
1932
1930
|
// Enlighten the color.
|
|
1933
1931
|
const BACKGROUND_ENLIGHT = 0.7;
|
|
1934
|
-
popup.style.backgroundColor = Util.makeHexColor(
|
|
1935
|
-
// @ts-expect-error TS(2556):
|
|
1936
|
-
...__classPrivateFieldGet(this, _PopupElement_color, "f").map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
|
|
1932
|
+
popup.style.backgroundColor = Util.makeHexColor(...__classPrivateFieldGet(this, _PopupElement_color, "f").map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
|
|
1937
1933
|
}
|
|
1938
1934
|
}
|
|
1939
1935
|
const header = document.createElement("span");
|
|
@@ -1954,7 +1950,6 @@ class PopupElement {
|
|
|
1954
1950
|
}
|
|
1955
1951
|
const html = __classPrivateFieldGet(this, _PopupElement_instances, "a", _PopupElement_html_get);
|
|
1956
1952
|
if (html) {
|
|
1957
|
-
// @ts-expect-error TS(2556):
|
|
1958
1953
|
XfaLayer.render({
|
|
1959
1954
|
xfaHtml: html,
|
|
1960
1955
|
intent: "richText",
|
|
@@ -530,7 +530,6 @@ class FreeTextEditor extends AnnotationEditor {
|
|
|
530
530
|
}
|
|
531
531
|
const editor = super.deserialize(data, parent, uiManager);
|
|
532
532
|
__classPrivateFieldSet(editor, _FreeTextEditor_fontSize, data.fontSize, "f");
|
|
533
|
-
// @ts-expect-error TS(2556):
|
|
534
533
|
__classPrivateFieldSet(editor, _FreeTextEditor_color, Util.makeHexColor(...data.color), "f");
|
|
535
534
|
__classPrivateFieldSet(editor, _FreeTextEditor_content, __classPrivateFieldGet(_a, _a, "m", _FreeTextEditor_deserializeContent).call(_a, data.value), "f");
|
|
536
535
|
editor.annotationElementId = data.id || null;
|
|
@@ -126,7 +126,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
126
126
|
/** @inheritdoc */
|
|
127
127
|
static updateDefaultParams(type, value) {
|
|
128
128
|
switch (type) {
|
|
129
|
-
case AnnotationEditorParamsType.
|
|
129
|
+
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
130
130
|
_a._defaultColor = value;
|
|
131
131
|
break;
|
|
132
132
|
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
|
@@ -157,7 +157,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
157
157
|
static get defaultPropertiesToUpdate() {
|
|
158
158
|
return [
|
|
159
159
|
[
|
|
160
|
-
AnnotationEditorParamsType.
|
|
160
|
+
AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
|
161
161
|
_a._defaultColor
|
|
162
162
|
],
|
|
163
163
|
[
|
|
@@ -404,7 +404,6 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
404
404
|
static deserialize(data, parent, uiManager) {
|
|
405
405
|
const editor = super.deserialize(data, parent, uiManager);
|
|
406
406
|
const { rect: [blX, blY, trX, trY], color, quadPoints } = data;
|
|
407
|
-
// @ts-expect-error TS()
|
|
408
407
|
editor.color = Util.makeHexColor(...color);
|
|
409
408
|
__classPrivateFieldSet(editor, _HighlightEditor_opacity, data.opacity, "f");
|
|
410
409
|
const [pageWidth, pageHeight] = editor.pageDimensions;
|
|
@@ -721,9 +721,8 @@ _FreeHighlightOutline_box = new WeakMap(), _FreeHighlightOutline_bbox = new Weak
|
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
else {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
...outline.slice(i, i + 6));
|
|
724
|
+
// pdfjs-dist legacy types declare bezierBoundingBox as void/9-arg but it returns the bbox array at runtime
|
|
725
|
+
const bbox = Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6));
|
|
727
726
|
minX = Math.min(minX, bbox[0]);
|
|
728
727
|
minY = Math.min(minY, bbox[1]);
|
|
729
728
|
maxX = Math.max(maxX, bbox[2]);
|
package/dist/es/annotations.js
CHANGED
package/dist/es/common/core.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Component } from "./component";
|
|
2
1
|
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
|
|
3
2
|
export const extend = (...args) => Object.assign(...args);
|
|
4
3
|
export const isObject = (value) => value && typeof (value) === "object" && !Array.isArray(value);
|
|
@@ -18,7 +17,7 @@ export const deepExtend = (target, ...sources) => {
|
|
|
18
17
|
if (key === '__proto__' || key === 'constructor') {
|
|
19
18
|
continue;
|
|
20
19
|
}
|
|
21
|
-
if (source[key]
|
|
20
|
+
if (source[key] && source[key].__isComponent) {
|
|
22
21
|
target[key] = source[key];
|
|
23
22
|
}
|
|
24
23
|
else if (isHtmlElement(source[key])) {
|
package/dist/es/common/dom.js
CHANGED
|
@@ -9,3 +9,29 @@ export const hasClass = (className, element) => {
|
|
|
9
9
|
return element.classList.contains(className);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
+
export const createElement = function (name, className, styles) {
|
|
13
|
+
const element = document.createElement(name);
|
|
14
|
+
if (className) {
|
|
15
|
+
element.className = className;
|
|
16
|
+
}
|
|
17
|
+
Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Scrolls the PDFViewer document to the passed page number.
|
|
22
|
+
*
|
|
23
|
+
* @param rootElement The root HTML element of the PDFViewer component.
|
|
24
|
+
* @param pageNumber The page number.
|
|
25
|
+
*/
|
|
26
|
+
export const scrollToPage = (rootElement, pageNumber) => {
|
|
27
|
+
const pages = rootElement.querySelectorAll('.k-page');
|
|
28
|
+
const page = pages[0];
|
|
29
|
+
if (page instanceof HTMLDivElement) {
|
|
30
|
+
const top = (page.offsetHeight + page.offsetTop) *
|
|
31
|
+
Math.max(0, Math.min(pageNumber, pages.length - 1));
|
|
32
|
+
const scrollElement = page.closest('.k-pdf-viewer-canvas');
|
|
33
|
+
if (scrollElement) {
|
|
34
|
+
scrollElement.scrollTo({ top, behavior: 'auto' });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es/utils.js
CHANGED
|
@@ -2,6 +2,8 @@ import { saveAs } from '@progress/kendo-file-saver';
|
|
|
2
2
|
import { detectDesktopBrowser, detectMobileOS } from '@progress/kendo-common';
|
|
3
3
|
import { getDocument, TextLayer } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
4
4
|
import { LinkAnnotation } from './annotations';
|
|
5
|
+
import { createElement, scrollToPage } from './common/dom';
|
|
6
|
+
export { createElement, scrollToPage };
|
|
5
7
|
const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
|
|
6
8
|
const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
|
|
7
9
|
const MAX_CANVAS_WIDTH_HEIGHT_FIREFOX = 32767;
|
|
@@ -217,7 +219,7 @@ const createEmptyPage = (page, zoom, pdfDoc, rootElement) => {
|
|
|
217
219
|
};
|
|
218
220
|
const renderCanvas = (page, done, error) => {
|
|
219
221
|
const { canvasContext, viewport, scaleNum, canvas, pageElement } = createCanvas(page);
|
|
220
|
-
page.render({ canvasContext, viewport })
|
|
222
|
+
page.render({ canvasContext, viewport, canvas })
|
|
221
223
|
.promise.then(() => {
|
|
222
224
|
const printContent = new Image(Math.floor((viewport.width / scaleNum)), Math.floor((viewport.height / scaleNum)));
|
|
223
225
|
printContent.src = canvas.toDataURL();
|
|
@@ -230,14 +232,6 @@ const renderCanvas = (page, done, error) => {
|
|
|
230
232
|
.catch(error);
|
|
231
233
|
return viewport;
|
|
232
234
|
};
|
|
233
|
-
export const createElement = function (name, className, styles) {
|
|
234
|
-
const element = document.createElement(name);
|
|
235
|
-
if (className) {
|
|
236
|
-
element.className = className;
|
|
237
|
-
}
|
|
238
|
-
Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
|
|
239
|
-
return element;
|
|
240
|
-
};
|
|
241
235
|
export const transforms = {
|
|
242
236
|
'0': '',
|
|
243
237
|
'90': 'rotate(90deg) translateY(-100%)',
|
|
@@ -245,9 +239,9 @@ export const transforms = {
|
|
|
245
239
|
'270': 'rotate(270deg) translateX(-100%)'
|
|
246
240
|
};
|
|
247
241
|
export const renderPage = (page, emptyPage, error) => {
|
|
248
|
-
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement } = emptyPage;
|
|
242
|
+
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement, canvas } = emptyPage;
|
|
249
243
|
page._pageInfo.renderInProgress = true;
|
|
250
|
-
page.render({ canvasContext, viewport })
|
|
244
|
+
page.render({ canvasContext, viewport, canvas })
|
|
251
245
|
.promise.then(() => {
|
|
252
246
|
page.getTextContent().then((textContent) => {
|
|
253
247
|
const textLayer = createElement('div', 'k-text-layer', styles);
|
|
@@ -364,24 +358,6 @@ export const calculateZoomLevel = (zoomLevel, zoomLevelType, currentZoom, dom) =
|
|
|
364
358
|
}
|
|
365
359
|
return calculatedZoomLevel;
|
|
366
360
|
};
|
|
367
|
-
/**
|
|
368
|
-
* Scrolls the PDFViewer document to the passed page number.
|
|
369
|
-
*
|
|
370
|
-
* @param rootElement The root HTML element of the PDFViewer component.
|
|
371
|
-
* @param pageNumber The page number.
|
|
372
|
-
*/
|
|
373
|
-
export const scrollToPage = (rootElement, pageNumber) => {
|
|
374
|
-
const pages = rootElement.querySelectorAll('.k-page');
|
|
375
|
-
const page = pages[0];
|
|
376
|
-
if (page instanceof HTMLDivElement) {
|
|
377
|
-
const top = (page.offsetHeight + page.offsetTop) *
|
|
378
|
-
Math.max(0, Math.min(pageNumber, pages.length - 1));
|
|
379
|
-
const scrollElement = page.closest('.k-pdf-viewer-canvas');
|
|
380
|
-
if (scrollElement) {
|
|
381
|
-
scrollElement.scrollTo({ top, behavior: 'auto' });
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
361
|
/**
|
|
386
362
|
* A function which gives you the page number of the document according to the scroll position.
|
|
387
363
|
*
|
package/dist/es/widget/page.js
CHANGED
|
@@ -572,6 +572,7 @@ export class Page extends Component {
|
|
|
572
572
|
canvasContext: canvasContext,
|
|
573
573
|
// transform,
|
|
574
574
|
viewport,
|
|
575
|
+
canvas,
|
|
575
576
|
annotationMode: __classPrivateFieldGet(this, _Page_annotationMode, "f"),
|
|
576
577
|
// optionalContentConfigPromise: this._optionalContentConfigPromise,
|
|
577
578
|
annotationCanvasMap: this._annotationCanvasMap,
|
|
@@ -1339,6 +1339,9 @@ export class PdfViewer extends Component {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
setScaleFactor(scaleFactor) {
|
|
1341
1341
|
this.element.style.setProperty('--scale-factor', String(scaleFactor * PixelsPerInch.PDF_TO_CSS_UNITS));
|
|
1342
|
+
this.element.style.setProperty('--total-scale-factor', String(scaleFactor * PixelsPerInch.PDF_TO_CSS_UNITS));
|
|
1343
|
+
this.element.style.setProperty('--scale-round-x', '1px');
|
|
1344
|
+
this.element.style.setProperty('--scale-round-y', '1px');
|
|
1342
1345
|
}
|
|
1343
1346
|
activatePageNumber(pageNumber) {
|
|
1344
1347
|
const page = this.getPageByNumber(pageNumber);
|
|
@@ -869,7 +869,7 @@ export class AnnotationEditorUIManager {
|
|
|
869
869
|
case AnnotationEditorParamsType.CREATE:
|
|
870
870
|
this.currentLayer.addNewEditor();
|
|
871
871
|
return;
|
|
872
|
-
case AnnotationEditorParamsType.
|
|
872
|
+
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
873
873
|
// this.#mainHighlightColorPicker?.updateColor(value);
|
|
874
874
|
break;
|
|
875
875
|
case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
|
|
@@ -1917,9 +1917,7 @@ class PopupElement {
|
|
|
1917
1917
|
const popup = (__classPrivateFieldSet(this, _PopupElement_popup, document.createElement("div"), "f"));
|
|
1918
1918
|
popup.className = "popup";
|
|
1919
1919
|
if (__classPrivateFieldGet(this, _PopupElement_color, "f")) {
|
|
1920
|
-
const baseColor = (popup.style.outlineColor = Util.makeHexColor(
|
|
1921
|
-
// @ts-expect-error TS(2556):
|
|
1922
|
-
...__classPrivateFieldGet(this, _PopupElement_color, "f")));
|
|
1920
|
+
const baseColor = (popup.style.outlineColor = Util.makeHexColor(...__classPrivateFieldGet(this, _PopupElement_color, "f")));
|
|
1923
1921
|
if (
|
|
1924
1922
|
// (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
|
1925
1923
|
CSS.supports("background-color", "color-mix(in srgb, red 30%, white)")) {
|
|
@@ -1931,9 +1929,7 @@ class PopupElement {
|
|
|
1931
1929
|
// TODO: Use color-mix when it's supported everywhere.
|
|
1932
1930
|
// Enlighten the color.
|
|
1933
1931
|
const BACKGROUND_ENLIGHT = 0.7;
|
|
1934
|
-
popup.style.backgroundColor = Util.makeHexColor(
|
|
1935
|
-
// @ts-expect-error TS(2556):
|
|
1936
|
-
...__classPrivateFieldGet(this, _PopupElement_color, "f").map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
|
|
1932
|
+
popup.style.backgroundColor = Util.makeHexColor(...__classPrivateFieldGet(this, _PopupElement_color, "f").map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
|
|
1937
1933
|
}
|
|
1938
1934
|
}
|
|
1939
1935
|
const header = document.createElement("span");
|
|
@@ -1954,7 +1950,6 @@ class PopupElement {
|
|
|
1954
1950
|
}
|
|
1955
1951
|
const html = __classPrivateFieldGet(this, _PopupElement_instances, "a", _PopupElement_html_get);
|
|
1956
1952
|
if (html) {
|
|
1957
|
-
// @ts-expect-error TS(2556):
|
|
1958
1953
|
XfaLayer.render({
|
|
1959
1954
|
xfaHtml: html,
|
|
1960
1955
|
intent: "richText",
|
|
@@ -530,7 +530,6 @@ class FreeTextEditor extends AnnotationEditor {
|
|
|
530
530
|
}
|
|
531
531
|
const editor = super.deserialize(data, parent, uiManager);
|
|
532
532
|
__classPrivateFieldSet(editor, _FreeTextEditor_fontSize, data.fontSize, "f");
|
|
533
|
-
// @ts-expect-error TS(2556):
|
|
534
533
|
__classPrivateFieldSet(editor, _FreeTextEditor_color, Util.makeHexColor(...data.color), "f");
|
|
535
534
|
__classPrivateFieldSet(editor, _FreeTextEditor_content, __classPrivateFieldGet(_a, _a, "m", _FreeTextEditor_deserializeContent).call(_a, data.value), "f");
|
|
536
535
|
editor.annotationElementId = data.id || null;
|
|
@@ -126,7 +126,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
126
126
|
/** @inheritdoc */
|
|
127
127
|
static updateDefaultParams(type, value) {
|
|
128
128
|
switch (type) {
|
|
129
|
-
case AnnotationEditorParamsType.
|
|
129
|
+
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
130
130
|
_a._defaultColor = value;
|
|
131
131
|
break;
|
|
132
132
|
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
|
@@ -157,7 +157,7 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
157
157
|
static get defaultPropertiesToUpdate() {
|
|
158
158
|
return [
|
|
159
159
|
[
|
|
160
|
-
AnnotationEditorParamsType.
|
|
160
|
+
AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
|
161
161
|
_a._defaultColor
|
|
162
162
|
],
|
|
163
163
|
[
|
|
@@ -404,7 +404,6 @@ class HighlightEditor extends AnnotationEditor {
|
|
|
404
404
|
static deserialize(data, parent, uiManager) {
|
|
405
405
|
const editor = super.deserialize(data, parent, uiManager);
|
|
406
406
|
const { rect: [blX, blY, trX, trY], color, quadPoints } = data;
|
|
407
|
-
// @ts-expect-error TS()
|
|
408
407
|
editor.color = Util.makeHexColor(...color);
|
|
409
408
|
__classPrivateFieldSet(editor, _HighlightEditor_opacity, data.opacity, "f");
|
|
410
409
|
const [pageWidth, pageHeight] = editor.pageDimensions;
|
|
@@ -721,9 +721,8 @@ _FreeHighlightOutline_box = new WeakMap(), _FreeHighlightOutline_bbox = new Weak
|
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
else {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
...outline.slice(i, i + 6));
|
|
724
|
+
// pdfjs-dist legacy types declare bezierBoundingBox as void/9-arg but it returns the bbox array at runtime
|
|
725
|
+
const bbox = Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6));
|
|
727
726
|
minX = Math.min(minX, bbox[0]);
|
|
728
727
|
minY = Math.min(minY, bbox[1]);
|
|
729
728
|
maxX = Math.max(maxX, bbox[2]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Component } from "./component";
|
|
2
1
|
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
|
|
3
2
|
export const extend = (...args) => Object.assign(...args);
|
|
4
3
|
export const isObject = (value) => value && typeof (value) === "object" && !Array.isArray(value);
|
|
@@ -18,7 +17,7 @@ export const deepExtend = (target, ...sources) => {
|
|
|
18
17
|
if (key === '__proto__' || key === 'constructor') {
|
|
19
18
|
continue;
|
|
20
19
|
}
|
|
21
|
-
if (source[key]
|
|
20
|
+
if (source[key] && source[key].__isComponent) {
|
|
22
21
|
target[key] = source[key];
|
|
23
22
|
}
|
|
24
23
|
else if (isHtmlElement(source[key])) {
|
|
@@ -9,3 +9,29 @@ export const hasClass = (className, element) => {
|
|
|
9
9
|
return element.classList.contains(className);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
+
export const createElement = function (name, className, styles) {
|
|
13
|
+
const element = document.createElement(name);
|
|
14
|
+
if (className) {
|
|
15
|
+
element.className = className;
|
|
16
|
+
}
|
|
17
|
+
Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Scrolls the PDFViewer document to the passed page number.
|
|
22
|
+
*
|
|
23
|
+
* @param rootElement The root HTML element of the PDFViewer component.
|
|
24
|
+
* @param pageNumber The page number.
|
|
25
|
+
*/
|
|
26
|
+
export const scrollToPage = (rootElement, pageNumber) => {
|
|
27
|
+
const pages = rootElement.querySelectorAll('.k-page');
|
|
28
|
+
const page = pages[0];
|
|
29
|
+
if (page instanceof HTMLDivElement) {
|
|
30
|
+
const top = (page.offsetHeight + page.offsetTop) *
|
|
31
|
+
Math.max(0, Math.min(pageNumber, pages.length - 1));
|
|
32
|
+
const scrollElement = page.closest('.k-pdf-viewer-canvas');
|
|
33
|
+
if (scrollElement) {
|
|
34
|
+
scrollElement.scrollTo({ top, behavior: 'auto' });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2015/utils.js
CHANGED
|
@@ -2,6 +2,8 @@ import { saveAs } from '@progress/kendo-file-saver';
|
|
|
2
2
|
import { detectDesktopBrowser, detectMobileOS } from '@progress/kendo-common';
|
|
3
3
|
import { getDocument, TextLayer } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
4
4
|
import { LinkAnnotation } from './annotations';
|
|
5
|
+
import { createElement, scrollToPage } from './common/dom';
|
|
6
|
+
export { createElement, scrollToPage };
|
|
5
7
|
const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
|
|
6
8
|
const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
|
|
7
9
|
const MAX_CANVAS_WIDTH_HEIGHT_FIREFOX = 32767;
|
|
@@ -217,7 +219,7 @@ const createEmptyPage = (page, zoom, pdfDoc, rootElement) => {
|
|
|
217
219
|
};
|
|
218
220
|
const renderCanvas = (page, done, error) => {
|
|
219
221
|
const { canvasContext, viewport, scaleNum, canvas, pageElement } = createCanvas(page);
|
|
220
|
-
page.render({ canvasContext, viewport })
|
|
222
|
+
page.render({ canvasContext, viewport, canvas })
|
|
221
223
|
.promise.then(() => {
|
|
222
224
|
const printContent = new Image(Math.floor((viewport.width / scaleNum)), Math.floor((viewport.height / scaleNum)));
|
|
223
225
|
printContent.src = canvas.toDataURL();
|
|
@@ -230,14 +232,6 @@ const renderCanvas = (page, done, error) => {
|
|
|
230
232
|
.catch(error);
|
|
231
233
|
return viewport;
|
|
232
234
|
};
|
|
233
|
-
export const createElement = function (name, className, styles) {
|
|
234
|
-
const element = document.createElement(name);
|
|
235
|
-
if (className) {
|
|
236
|
-
element.className = className;
|
|
237
|
-
}
|
|
238
|
-
Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
|
|
239
|
-
return element;
|
|
240
|
-
};
|
|
241
235
|
export const transforms = {
|
|
242
236
|
'0': '',
|
|
243
237
|
'90': 'rotate(90deg) translateY(-100%)',
|
|
@@ -245,9 +239,9 @@ export const transforms = {
|
|
|
245
239
|
'270': 'rotate(270deg) translateX(-100%)'
|
|
246
240
|
};
|
|
247
241
|
export const renderPage = (page, emptyPage, error) => {
|
|
248
|
-
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement } = emptyPage;
|
|
242
|
+
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement, canvas } = emptyPage;
|
|
249
243
|
page._pageInfo.renderInProgress = true;
|
|
250
|
-
page.render({ canvasContext, viewport })
|
|
244
|
+
page.render({ canvasContext, viewport, canvas })
|
|
251
245
|
.promise.then(() => {
|
|
252
246
|
page.getTextContent().then((textContent) => {
|
|
253
247
|
const textLayer = createElement('div', 'k-text-layer', styles);
|
|
@@ -364,24 +358,6 @@ export const calculateZoomLevel = (zoomLevel, zoomLevelType, currentZoom, dom) =
|
|
|
364
358
|
}
|
|
365
359
|
return calculatedZoomLevel;
|
|
366
360
|
};
|
|
367
|
-
/**
|
|
368
|
-
* Scrolls the PDFViewer document to the passed page number.
|
|
369
|
-
*
|
|
370
|
-
* @param rootElement The root HTML element of the PDFViewer component.
|
|
371
|
-
* @param pageNumber The page number.
|
|
372
|
-
*/
|
|
373
|
-
export const scrollToPage = (rootElement, pageNumber) => {
|
|
374
|
-
const pages = rootElement.querySelectorAll('.k-page');
|
|
375
|
-
const page = pages[0];
|
|
376
|
-
if (page instanceof HTMLDivElement) {
|
|
377
|
-
const top = (page.offsetHeight + page.offsetTop) *
|
|
378
|
-
Math.max(0, Math.min(pageNumber, pages.length - 1));
|
|
379
|
-
const scrollElement = page.closest('.k-pdf-viewer-canvas');
|
|
380
|
-
if (scrollElement) {
|
|
381
|
-
scrollElement.scrollTo({ top, behavior: 'auto' });
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
361
|
/**
|
|
386
362
|
* A function which gives you the page number of the document according to the scroll position.
|
|
387
363
|
*
|
|
@@ -572,6 +572,7 @@ export class Page extends Component {
|
|
|
572
572
|
canvasContext: canvasContext,
|
|
573
573
|
// transform,
|
|
574
574
|
viewport,
|
|
575
|
+
canvas,
|
|
575
576
|
annotationMode: __classPrivateFieldGet(this, _Page_annotationMode, "f"),
|
|
576
577
|
// optionalContentConfigPromise: this._optionalContentConfigPromise,
|
|
577
578
|
annotationCanvasMap: this._annotationCanvasMap,
|
|
@@ -1339,6 +1339,9 @@ export class PdfViewer extends Component {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
setScaleFactor(scaleFactor) {
|
|
1341
1341
|
this.element.style.setProperty('--scale-factor', String(scaleFactor * PixelsPerInch.PDF_TO_CSS_UNITS));
|
|
1342
|
+
this.element.style.setProperty('--total-scale-factor', String(scaleFactor * PixelsPerInch.PDF_TO_CSS_UNITS));
|
|
1343
|
+
this.element.style.setProperty('--scale-round-x', '1px');
|
|
1344
|
+
this.element.style.setProperty('--scale-round-y', '1px');
|
|
1342
1345
|
}
|
|
1343
1346
|
activatePageNumber(pageNumber) {
|
|
1344
1347
|
const page = this.getPageByNumber(pageNumber);
|
|
@@ -872,7 +872,7 @@ class AnnotationEditorUIManager {
|
|
|
872
872
|
case pdf_mjs_1.AnnotationEditorParamsType.CREATE:
|
|
873
873
|
this.currentLayer.addNewEditor();
|
|
874
874
|
return;
|
|
875
|
-
case pdf_mjs_1.AnnotationEditorParamsType.
|
|
875
|
+
case pdf_mjs_1.AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
876
876
|
// this.#mainHighlightColorPicker?.updateColor(value);
|
|
877
877
|
break;
|
|
878
878
|
case pdf_mjs_1.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
|
|
@@ -1920,9 +1920,7 @@ class PopupElement {
|
|
|
1920
1920
|
const popup = (tslib_1.__classPrivateFieldSet(this, _PopupElement_popup, document.createElement("div"), "f"));
|
|
1921
1921
|
popup.className = "popup";
|
|
1922
1922
|
if (tslib_1.__classPrivateFieldGet(this, _PopupElement_color, "f")) {
|
|
1923
|
-
const baseColor = (popup.style.outlineColor = pdf_mjs_1.Util.makeHexColor(
|
|
1924
|
-
// @ts-expect-error TS(2556):
|
|
1925
|
-
...tslib_1.__classPrivateFieldGet(this, _PopupElement_color, "f")));
|
|
1923
|
+
const baseColor = (popup.style.outlineColor = pdf_mjs_1.Util.makeHexColor(...tslib_1.__classPrivateFieldGet(this, _PopupElement_color, "f")));
|
|
1926
1924
|
if (
|
|
1927
1925
|
// (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
|
1928
1926
|
CSS.supports("background-color", "color-mix(in srgb, red 30%, white)")) {
|
|
@@ -1934,9 +1932,7 @@ class PopupElement {
|
|
|
1934
1932
|
// TODO: Use color-mix when it's supported everywhere.
|
|
1935
1933
|
// Enlighten the color.
|
|
1936
1934
|
const BACKGROUND_ENLIGHT = 0.7;
|
|
1937
|
-
popup.style.backgroundColor = pdf_mjs_1.Util.makeHexColor(
|
|
1938
|
-
// @ts-expect-error TS(2556):
|
|
1939
|
-
...tslib_1.__classPrivateFieldGet(this, _PopupElement_color, "f").map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
|
|
1935
|
+
popup.style.backgroundColor = pdf_mjs_1.Util.makeHexColor(...tslib_1.__classPrivateFieldGet(this, _PopupElement_color, "f").map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
|
|
1940
1936
|
}
|
|
1941
1937
|
}
|
|
1942
1938
|
const header = document.createElement("span");
|
|
@@ -1957,7 +1953,6 @@ class PopupElement {
|
|
|
1957
1953
|
}
|
|
1958
1954
|
const html = tslib_1.__classPrivateFieldGet(this, _PopupElement_instances, "a", _PopupElement_html_get);
|
|
1959
1955
|
if (html) {
|
|
1960
|
-
// @ts-expect-error TS(2556):
|
|
1961
1956
|
pdf_mjs_1.XfaLayer.render({
|
|
1962
1957
|
xfaHtml: html,
|
|
1963
1958
|
intent: "richText",
|
|
@@ -533,7 +533,6 @@ class FreeTextEditor extends annotation_editor_1.AnnotationEditor {
|
|
|
533
533
|
}
|
|
534
534
|
const editor = super.deserialize(data, parent, uiManager);
|
|
535
535
|
tslib_1.__classPrivateFieldSet(editor, _FreeTextEditor_fontSize, data.fontSize, "f");
|
|
536
|
-
// @ts-expect-error TS(2556):
|
|
537
536
|
tslib_1.__classPrivateFieldSet(editor, _FreeTextEditor_color, pdf_mjs_1.Util.makeHexColor(...data.color), "f");
|
|
538
537
|
tslib_1.__classPrivateFieldSet(editor, _FreeTextEditor_content, tslib_1.__classPrivateFieldGet(_a, _a, "m", _FreeTextEditor_deserializeContent).call(_a, data.value), "f");
|
|
539
538
|
editor.annotationElementId = data.id || null;
|
|
@@ -126,7 +126,7 @@ class HighlightEditor extends annotation_editor_1.AnnotationEditor {
|
|
|
126
126
|
/** @inheritdoc */
|
|
127
127
|
static updateDefaultParams(type, value) {
|
|
128
128
|
switch (type) {
|
|
129
|
-
case pdf_mjs_1.AnnotationEditorParamsType.
|
|
129
|
+
case pdf_mjs_1.AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
130
130
|
_a._defaultColor = value;
|
|
131
131
|
break;
|
|
132
132
|
case pdf_mjs_1.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
|
@@ -157,7 +157,7 @@ class HighlightEditor extends annotation_editor_1.AnnotationEditor {
|
|
|
157
157
|
static get defaultPropertiesToUpdate() {
|
|
158
158
|
return [
|
|
159
159
|
[
|
|
160
|
-
pdf_mjs_1.AnnotationEditorParamsType.
|
|
160
|
+
pdf_mjs_1.AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
|
161
161
|
_a._defaultColor
|
|
162
162
|
],
|
|
163
163
|
[
|
|
@@ -404,7 +404,6 @@ class HighlightEditor extends annotation_editor_1.AnnotationEditor {
|
|
|
404
404
|
static deserialize(data, parent, uiManager) {
|
|
405
405
|
const editor = super.deserialize(data, parent, uiManager);
|
|
406
406
|
const { rect: [blX, blY, trX, trY], color, quadPoints } = data;
|
|
407
|
-
// @ts-expect-error TS()
|
|
408
407
|
editor.color = pdf_mjs_1.Util.makeHexColor(...color);
|
|
409
408
|
tslib_1.__classPrivateFieldSet(editor, _HighlightEditor_opacity, data.opacity, "f");
|
|
410
409
|
const [pageWidth, pageHeight] = editor.pageDimensions;
|
|
@@ -726,9 +726,8 @@ _FreeHighlightOutline_box = new WeakMap(), _FreeHighlightOutline_bbox = new Weak
|
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
else {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
...outline.slice(i, i + 6));
|
|
729
|
+
// pdfjs-dist legacy types declare bezierBoundingBox as void/9-arg but it returns the bbox array at runtime
|
|
730
|
+
const bbox = pdf_mjs_1.Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6));
|
|
732
731
|
minX = Math.min(minX, bbox[0]);
|
|
733
732
|
minY = Math.min(minY, bbox[1]);
|
|
734
733
|
maxX = Math.max(maxX, bbox[2]);
|
package/dist/npm/annotations.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkAnnotation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const dom_1 = require("./common/dom");
|
|
5
5
|
class Annotation {
|
|
6
6
|
constructor(container, viewport, annotation, pdfDoc, zoom, rootElement) {
|
|
7
7
|
this.container = container;
|
|
@@ -43,7 +43,7 @@ class LinkAnnotation extends Annotation {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
goToPage(pageNumber) {
|
|
46
|
-
(0,
|
|
46
|
+
(0, dom_1.scrollToPage)(this.rootElement, pageNumber);
|
|
47
47
|
}
|
|
48
48
|
renderAnnotation() {
|
|
49
49
|
const annotation = this.annotation, viewport = this.viewport, rect = annotation.rect, boundingRect = [
|
|
@@ -52,12 +52,12 @@ class LinkAnnotation extends Annotation {
|
|
|
52
52
|
], rawHeight = viewport.rawDims.pageHeight;
|
|
53
53
|
const left = Math.min(boundingRect[0][0], boundingRect[1][0]) * this.zoom, top = (rawHeight - Math.max(boundingRect[0][1], boundingRect[1][1])) * this.zoom, width = (boundingRect[1][0] - boundingRect[0][0]) * this.zoom, height = (boundingRect[1][1] - boundingRect[0][1]) * this.zoom;
|
|
54
54
|
const url = annotation.url || (annotation.dest && `#${encodeURI(annotation.dest)}`);
|
|
55
|
-
const annotationElement = (0,
|
|
55
|
+
const annotationElement = (0, dom_1.createElement)('span', '', {
|
|
56
56
|
position: 'absolute',
|
|
57
57
|
left: left + 'pt',
|
|
58
58
|
top: top + 'pt'
|
|
59
59
|
});
|
|
60
|
-
const linkElement = this.linkElement = (0,
|
|
60
|
+
const linkElement = this.linkElement = (0, dom_1.createElement)('a', '', {
|
|
61
61
|
width: width + 'pt',
|
|
62
62
|
height: height + 'pt',
|
|
63
63
|
display: 'inline-block',
|
package/dist/npm/common/core.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createPromise = exports.mousewheelDelta = exports.toClassSelector = exports.toPixel = exports.convertToHtml = exports.noop = exports.hasValue = exports.isNotNull = exports.isDefined = exports.toArray = exports.isString = exports.isFunction = exports.deepExtend = exports.isDotNetObject = exports.isDomElement = exports.isHtmlElement = exports.isObject = exports.extend = void 0;
|
|
4
|
-
const component_1 = require("./component");
|
|
5
4
|
// @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
|
|
6
5
|
const extend = (...args) => Object.assign(...args);
|
|
7
6
|
exports.extend = extend;
|
|
@@ -26,7 +25,7 @@ const deepExtend = (target, ...sources) => {
|
|
|
26
25
|
if (key === '__proto__' || key === 'constructor') {
|
|
27
26
|
continue;
|
|
28
27
|
}
|
|
29
|
-
if (source[key]
|
|
28
|
+
if (source[key] && source[key].__isComponent) {
|
|
30
29
|
target[key] = source[key];
|
|
31
30
|
}
|
|
32
31
|
else if ((0, exports.isHtmlElement)(source[key])) {
|
package/dist/npm/common/dom.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export declare const addClass: (className: any, element: any) => void;
|
|
2
2
|
export declare const removeClass: (className: any, element: any) => void;
|
|
3
3
|
export declare const hasClass: (className: any, element: any) => boolean;
|
|
4
|
+
export declare const createElement: <T>(name: string, className: string, styles: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
}) => T;
|
|
7
|
+
/**
|
|
8
|
+
* Scrolls the PDFViewer document to the passed page number.
|
|
9
|
+
*
|
|
10
|
+
* @param rootElement The root HTML element of the PDFViewer component.
|
|
11
|
+
* @param pageNumber The page number.
|
|
12
|
+
*/
|
|
13
|
+
export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
|
package/dist/npm/common/dom.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasClass = exports.removeClass = exports.addClass = void 0;
|
|
3
|
+
exports.scrollToPage = exports.createElement = exports.hasClass = exports.removeClass = exports.addClass = void 0;
|
|
4
4
|
const addClass = (className, element) => {
|
|
5
5
|
element.classList.add(className);
|
|
6
6
|
};
|
|
@@ -15,3 +15,31 @@ const hasClass = (className, element) => {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
exports.hasClass = hasClass;
|
|
18
|
+
const createElement = function (name, className, styles) {
|
|
19
|
+
const element = document.createElement(name);
|
|
20
|
+
if (className) {
|
|
21
|
+
element.className = className;
|
|
22
|
+
}
|
|
23
|
+
Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
|
|
24
|
+
return element;
|
|
25
|
+
};
|
|
26
|
+
exports.createElement = createElement;
|
|
27
|
+
/**
|
|
28
|
+
* Scrolls the PDFViewer document to the passed page number.
|
|
29
|
+
*
|
|
30
|
+
* @param rootElement The root HTML element of the PDFViewer component.
|
|
31
|
+
* @param pageNumber The page number.
|
|
32
|
+
*/
|
|
33
|
+
const scrollToPage = (rootElement, pageNumber) => {
|
|
34
|
+
const pages = rootElement.querySelectorAll('.k-page');
|
|
35
|
+
const page = pages[0];
|
|
36
|
+
if (page instanceof HTMLDivElement) {
|
|
37
|
+
const top = (page.offsetHeight + page.offsetTop) *
|
|
38
|
+
Math.max(0, Math.min(pageNumber, pages.length - 1));
|
|
39
|
+
const scrollElement = page.closest('.k-pdf-viewer-canvas');
|
|
40
|
+
if (scrollElement) {
|
|
41
|
+
scrollElement.scrollTo({ top, behavior: 'auto' });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.scrollToPage = scrollToPage;
|
package/dist/npm/main.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './search';
|
|
|
3
3
|
export * from './utils';
|
|
4
4
|
export * from './widget/pdfviewer';
|
|
5
5
|
export * from './enums/PdfViewerInteractionMode';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export type { TypedArray } from "./types";
|
|
7
|
+
export type { PDFDocumentProxy } from 'pdfjs-dist/types/src/display/api';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
package/dist/npm/utils.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SaveOptions } from '@progress/kendo-file-saver';
|
|
2
2
|
import { PDFPageProxy, PDFDocumentProxy } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
3
3
|
import { TypedArray } from "pdfjs-dist/types/src/display/api";
|
|
4
|
+
import { createElement, scrollToPage } from './common/dom';
|
|
5
|
+
export { createElement, scrollToPage };
|
|
4
6
|
/**
|
|
5
7
|
* @hidden
|
|
6
8
|
*/
|
|
@@ -75,9 +77,6 @@ export declare const reloadDocument: (params: PDFReloadParameters) => void;
|
|
|
75
77
|
* @hidden
|
|
76
78
|
*/
|
|
77
79
|
export declare const print: (pages: PDFPageProxy[], done: () => void, error: ErrorFn) => void;
|
|
78
|
-
export declare const createElement: <T>(name: string, className: string, styles: {
|
|
79
|
-
[key: string]: string;
|
|
80
|
-
}) => T;
|
|
81
80
|
export declare const transforms: {
|
|
82
81
|
[rotation: string]: string;
|
|
83
82
|
};
|
|
@@ -94,13 +93,6 @@ export declare const goToPreviousSearchMatch: (ref: any) => void;
|
|
|
94
93
|
* @hidden
|
|
95
94
|
*/
|
|
96
95
|
export declare const calculateZoomLevel: (zoomLevel: number, zoomLevelType: string, currentZoom: number, dom: HTMLDivElement) => number;
|
|
97
|
-
/**
|
|
98
|
-
* Scrolls the PDFViewer document to the passed page number.
|
|
99
|
-
*
|
|
100
|
-
* @param rootElement The root HTML element of the PDFViewer component.
|
|
101
|
-
* @param pageNumber The page number.
|
|
102
|
-
*/
|
|
103
|
-
export declare const scrollToPage: (rootElement: HTMLElement, pageNumber: number) => void;
|
|
104
96
|
/**
|
|
105
97
|
* A function which gives you the page number of the document according to the scroll position.
|
|
106
98
|
*
|
package/dist/npm/utils.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addAdoptedStylesheet = exports.getDevicePixelRatio = exports.adjustCanvasSize = exports.currentPage = exports.
|
|
3
|
+
exports.addAdoptedStylesheet = exports.getDevicePixelRatio = exports.adjustCanvasSize = exports.currentPage = exports.calculateZoomLevel = exports.goToPreviousSearchMatch = exports.goToNextSearchMatch = exports.renderPage = exports.transforms = exports.print = exports.reloadDocument = exports.loadPDF = exports.download = exports.removeChildren = exports.parsePdfFromBase64String = exports.scale = exports.DEFAULT_ZOOM_LEVEL = exports.scrollToPage = exports.createElement = 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");
|
|
7
7
|
const annotations_1 = require("./annotations");
|
|
8
|
+
const dom_1 = require("./common/dom");
|
|
9
|
+
Object.defineProperty(exports, "createElement", { enumerable: true, get: function () { return dom_1.createElement; } });
|
|
10
|
+
Object.defineProperty(exports, "scrollToPage", { enumerable: true, get: function () { return dom_1.scrollToPage; } });
|
|
8
11
|
const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
|
|
9
12
|
const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
|
|
10
13
|
const MAX_CANVAS_WIDTH_HEIGHT_FIREFOX = 32767;
|
|
@@ -163,7 +166,7 @@ const reloadDocument = (params) => {
|
|
|
163
166
|
if (loadOnDemand) {
|
|
164
167
|
const page = pdfPages[currentPageIndex];
|
|
165
168
|
(0, exports.renderPage)(page, page._pageInfo.emptyPage, error);
|
|
166
|
-
(0,
|
|
169
|
+
(0, dom_1.scrollToPage)(rootElement, currentPageIndex);
|
|
167
170
|
}
|
|
168
171
|
done(pdfPages);
|
|
169
172
|
})
|
|
@@ -227,7 +230,7 @@ const createEmptyPage = (page, zoom, pdfDoc, rootElement) => {
|
|
|
227
230
|
};
|
|
228
231
|
const renderCanvas = (page, done, error) => {
|
|
229
232
|
const { canvasContext, viewport, scaleNum, canvas, pageElement } = createCanvas(page);
|
|
230
|
-
page.render({ canvasContext, viewport })
|
|
233
|
+
page.render({ canvasContext, viewport, canvas })
|
|
231
234
|
.promise.then(() => {
|
|
232
235
|
const printContent = new Image(Math.floor((viewport.width / scaleNum)), Math.floor((viewport.height / scaleNum)));
|
|
233
236
|
printContent.src = canvas.toDataURL();
|
|
@@ -240,15 +243,6 @@ const renderCanvas = (page, done, error) => {
|
|
|
240
243
|
.catch(error);
|
|
241
244
|
return viewport;
|
|
242
245
|
};
|
|
243
|
-
const createElement = function (name, className, styles) {
|
|
244
|
-
const element = document.createElement(name);
|
|
245
|
-
if (className) {
|
|
246
|
-
element.className = className;
|
|
247
|
-
}
|
|
248
|
-
Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
|
|
249
|
-
return element;
|
|
250
|
-
};
|
|
251
|
-
exports.createElement = createElement;
|
|
252
246
|
exports.transforms = {
|
|
253
247
|
'0': '',
|
|
254
248
|
'90': 'rotate(90deg) translateY(-100%)',
|
|
@@ -256,12 +250,12 @@ exports.transforms = {
|
|
|
256
250
|
'270': 'rotate(270deg) translateX(-100%)'
|
|
257
251
|
};
|
|
258
252
|
const renderPage = (page, emptyPage, error) => {
|
|
259
|
-
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement } = emptyPage;
|
|
253
|
+
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement, canvas } = emptyPage;
|
|
260
254
|
page._pageInfo.renderInProgress = true;
|
|
261
|
-
page.render({ canvasContext, viewport })
|
|
255
|
+
page.render({ canvasContext, viewport, canvas })
|
|
262
256
|
.promise.then(() => {
|
|
263
257
|
page.getTextContent().then((textContent) => {
|
|
264
|
-
const textLayer = (0,
|
|
258
|
+
const textLayer = (0, dom_1.createElement)('div', 'k-text-layer', styles);
|
|
265
259
|
new pdf_mjs_1.TextLayer({
|
|
266
260
|
textContentSource: textContent,
|
|
267
261
|
container: textLayer,
|
|
@@ -283,7 +277,7 @@ const renderPage = (page, emptyPage, error) => {
|
|
|
283
277
|
}).catch(error);
|
|
284
278
|
});
|
|
285
279
|
page.getAnnotations({ intent: 'display' }).then((annotations) => {
|
|
286
|
-
const annotationLayer = (0,
|
|
280
|
+
const annotationLayer = (0, dom_1.createElement)('div', 'k-annotations-layer', {
|
|
287
281
|
position: 'absolute',
|
|
288
282
|
top: '0',
|
|
289
283
|
left: '0',
|
|
@@ -379,25 +373,6 @@ const calculateZoomLevel = (zoomLevel, zoomLevelType, currentZoom, dom) => {
|
|
|
379
373
|
return calculatedZoomLevel;
|
|
380
374
|
};
|
|
381
375
|
exports.calculateZoomLevel = calculateZoomLevel;
|
|
382
|
-
/**
|
|
383
|
-
* Scrolls the PDFViewer document to the passed page number.
|
|
384
|
-
*
|
|
385
|
-
* @param rootElement The root HTML element of the PDFViewer component.
|
|
386
|
-
* @param pageNumber The page number.
|
|
387
|
-
*/
|
|
388
|
-
const scrollToPage = (rootElement, pageNumber) => {
|
|
389
|
-
const pages = rootElement.querySelectorAll('.k-page');
|
|
390
|
-
const page = pages[0];
|
|
391
|
-
if (page instanceof HTMLDivElement) {
|
|
392
|
-
const top = (page.offsetHeight + page.offsetTop) *
|
|
393
|
-
Math.max(0, Math.min(pageNumber, pages.length - 1));
|
|
394
|
-
const scrollElement = page.closest('.k-pdf-viewer-canvas');
|
|
395
|
-
if (scrollElement) {
|
|
396
|
-
scrollElement.scrollTo({ top, behavior: 'auto' });
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
exports.scrollToPage = scrollToPage;
|
|
401
376
|
/**
|
|
402
377
|
* A function which gives you the page number of the document according to the scroll position.
|
|
403
378
|
*
|
|
@@ -469,8 +444,8 @@ const createCanvas = (page, zoom = 1, cssClass = '') => {
|
|
|
469
444
|
width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
|
|
470
445
|
height: Math.floor(viewport.height / scaleNum) * zoom + 'pt'
|
|
471
446
|
};
|
|
472
|
-
const pageElement = (0,
|
|
473
|
-
const canvas = (0,
|
|
447
|
+
const pageElement = (0, dom_1.createElement)('div', cssClass, styles);
|
|
448
|
+
const canvas = (0, dom_1.createElement)('canvas', '', {
|
|
474
449
|
width: '100%',
|
|
475
450
|
height: '100%'
|
|
476
451
|
});
|
package/dist/npm/widget/page.js
CHANGED
|
@@ -572,6 +572,7 @@ class Page extends component_1.Component {
|
|
|
572
572
|
canvasContext: canvasContext,
|
|
573
573
|
// transform,
|
|
574
574
|
viewport,
|
|
575
|
+
canvas,
|
|
575
576
|
annotationMode: tslib_1.__classPrivateFieldGet(this, _Page_annotationMode, "f"),
|
|
576
577
|
// optionalContentConfigPromise: this._optionalContentConfigPromise,
|
|
577
578
|
annotationCanvasMap: this._annotationCanvasMap,
|
|
@@ -1342,6 +1342,9 @@ class PdfViewer extends main_1.Component {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
setScaleFactor(scaleFactor) {
|
|
1344
1344
|
this.element.style.setProperty('--scale-factor', String(scaleFactor * pdf_mjs_1.PixelsPerInch.PDF_TO_CSS_UNITS));
|
|
1345
|
+
this.element.style.setProperty('--total-scale-factor', String(scaleFactor * pdf_mjs_1.PixelsPerInch.PDF_TO_CSS_UNITS));
|
|
1346
|
+
this.element.style.setProperty('--scale-round-x', '1px');
|
|
1347
|
+
this.element.style.setProperty('--scale-round-y', '1px');
|
|
1345
1348
|
}
|
|
1346
1349
|
activatePageNumber(pageNumber) {
|
|
1347
1350
|
const page = this.getPageByNumber(pageNumber);
|
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.
|
|
4
|
+
"version": "1.0.0-develop.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Kendo UI"
|
|
7
7
|
],
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"prepare": "npx husky",
|
|
20
|
-
"test": "
|
|
21
|
-
"test:ci": "
|
|
22
|
-
"watch-test": "
|
|
20
|
+
"test": "vitest run --config vitest.config.ts",
|
|
21
|
+
"test:ci": "vitest run --config vitest.config.ts",
|
|
22
|
+
"watch-test": "vitest run --config vitest.config.ts --watch",
|
|
23
23
|
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider gulp start",
|
|
24
24
|
"lint": "npx eslint",
|
|
25
25
|
"lint:fix": "npx eslint --fix",
|
|
@@ -28,52 +28,44 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@progress/kendo-draggable": "^3.1.0",
|
|
31
|
-
"@progress/kendo-file-saver": "^1.1.
|
|
31
|
+
"@progress/kendo-file-saver": "^1.1.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@progress/kendo-common": "1.0.2",
|
|
35
|
-
"pdfjs-dist": "
|
|
36
|
-
"tslib": "^2.
|
|
35
|
+
"pdfjs-dist": "5.6.205",
|
|
36
|
+
"tslib": "^2.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@babel/preset-env": "^7.
|
|
40
|
-
"@commitlint/cli": "^
|
|
41
|
-
"@commitlint/config-conventional": "^
|
|
42
|
-
"@eslint/js": "^
|
|
43
|
-
"@progress/kendo-common-tasks": "
|
|
39
|
+
"@babel/preset-env": "^7.29.0",
|
|
40
|
+
"@commitlint/cli": "^20.4.4",
|
|
41
|
+
"@commitlint/config-conventional": "^20.4.4",
|
|
42
|
+
"@eslint/js": "^10.0.1",
|
|
43
|
+
"@progress/kendo-common-tasks": "^9.0.1",
|
|
44
44
|
"@progress/kendo-draggable": "^3.1.0",
|
|
45
|
-
"@progress/kendo-file-saver": "^1.1.
|
|
46
|
-
"@progress/kendo-typescript-tasks": "
|
|
47
|
-
"
|
|
48
|
-
"@types/jest": "^23.3.14",
|
|
49
|
-
"cross-env": "^7.0.3",
|
|
45
|
+
"@progress/kendo-file-saver": "^1.1.2",
|
|
46
|
+
"@progress/kendo-typescript-tasks": "^12.0.0",
|
|
47
|
+
"cross-env": "^10.1.0",
|
|
50
48
|
"cz-conventional-changelog": "^3.3.0",
|
|
51
|
-
"eslint": "^
|
|
52
|
-
"eslint-plugin-jsdoc": "^
|
|
49
|
+
"eslint": "^10.0.3",
|
|
50
|
+
"eslint-plugin-jsdoc": "^62.8.0",
|
|
53
51
|
"gulp": "^5.0.0",
|
|
54
52
|
"husky": "^9.1.7",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"typescript": "~5.7.3",
|
|
61
|
-
"typescript-eslint": "^8.21.0"
|
|
62
|
-
},
|
|
63
|
-
"overrides": {
|
|
64
|
-
"lodash": "4.17.23",
|
|
65
|
-
"tmp": "0.2.4",
|
|
66
|
-
"tar": ">=7.5.10",
|
|
67
|
-
"@tootallnate/once": ">=3.0.1",
|
|
68
|
-
"minimatch": ">=10.2.3",
|
|
69
|
-
"webpack": ">=5.104.1",
|
|
70
|
-
"qs": ">=6.14.2"
|
|
53
|
+
"jsdom": "^28.0.0",
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"typescript-eslint": "^8.54.0",
|
|
56
|
+
"vitest": "^4.1.3",
|
|
57
|
+
"vitest-canvas-mock": "^1.1.3"
|
|
71
58
|
},
|
|
72
59
|
"config": {
|
|
73
60
|
"commitizen": {
|
|
74
61
|
"path": "./node_modules/cz-conventional-changelog"
|
|
75
62
|
}
|
|
76
63
|
},
|
|
64
|
+
"overrides": {
|
|
65
|
+
"lodash": "^4.17.23",
|
|
66
|
+
"inquirer": "^9.2.0",
|
|
67
|
+
"uuid": "^14.0.0"
|
|
68
|
+
},
|
|
77
69
|
"repository": {
|
|
78
70
|
"type": "git",
|
|
79
71
|
"url": "https://github.com/telerik/kendo-pdfviewer-common.git"
|