@progress/kendo-pdfviewer-common 0.2.10 → 0.2.11-dev.202408260632
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/utils.js +18 -12
- package/dist/es2015/utils.js +18 -12
- package/dist/npm/utils.d.ts +1 -1
- package/dist/npm/utils.js +19 -13
- package/package.json +2 -2
package/dist/es/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { saveAs } from '@progress/kendo-file-saver';
|
|
2
2
|
import { detectDesktopBrowser, detectMobileOS } from '@progress/kendo-common';
|
|
3
|
-
import { getDocument,
|
|
3
|
+
import { getDocument, TextLayer } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
4
4
|
const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
|
|
5
5
|
const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
|
|
6
6
|
const MAX_CANVAS_WIDTH_HEIGHT_FIREFOX = 32767;
|
|
@@ -91,14 +91,23 @@ export const loadPDF = (options) => {
|
|
|
91
91
|
pages.push(pdfDoc.getPage(i));
|
|
92
92
|
}
|
|
93
93
|
return { pages, pdfDoc };
|
|
94
|
-
})
|
|
95
|
-
.then(({ pages, pdfDoc }) => {
|
|
94
|
+
}).then(({ pages, pdfDoc }) => {
|
|
96
95
|
Promise.all(pages)
|
|
97
96
|
.then((all) => all.map((page, i) => {
|
|
98
97
|
appendPage(dom, renderPage(page, zoom, error), i);
|
|
99
98
|
return page;
|
|
100
|
-
}))
|
|
101
|
-
|
|
99
|
+
})).then((pdfPages) => {
|
|
100
|
+
// required by new PDFJS version
|
|
101
|
+
const sheet = new CSSStyleSheet();
|
|
102
|
+
sheet.replaceSync(`.hiddenCanvasElement {
|
|
103
|
+
position: absolute;
|
|
104
|
+
top: 0;
|
|
105
|
+
left: 0;
|
|
106
|
+
width: 0;
|
|
107
|
+
height: 0;
|
|
108
|
+
display: none;
|
|
109
|
+
}`);
|
|
110
|
+
options.dom.ownerDocument.adoptedStyleSheets = [sheet];
|
|
102
111
|
done({ pdfPages, pdfDoc, zoom });
|
|
103
112
|
})
|
|
104
113
|
.catch((reason) => {
|
|
@@ -203,13 +212,11 @@ const renderPage = (page, zoom, error) => {
|
|
|
203
212
|
.promise.then(() => {
|
|
204
213
|
page.getTextContent().then((textContent) => {
|
|
205
214
|
const textLayer = createElement('div', 'k-text-layer', styles);
|
|
206
|
-
|
|
215
|
+
new TextLayer({
|
|
207
216
|
textContentSource: textContent,
|
|
208
217
|
container: textLayer,
|
|
209
|
-
viewport: viewport
|
|
210
|
-
|
|
211
|
-
})
|
|
212
|
-
.promise.then(() => {
|
|
218
|
+
viewport: viewport
|
|
219
|
+
}).render().then(() => {
|
|
213
220
|
textLayer.style.width = textLayer.style.width.replace(/px/g, 'pt');
|
|
214
221
|
textLayer.style.height = textLayer.style.height.replace(/px/g, 'pt');
|
|
215
222
|
const rotation = textLayer.getAttribute('data-main-rotation') || '0';
|
|
@@ -223,8 +230,7 @@ const renderPage = (page, zoom, error) => {
|
|
|
223
230
|
}
|
|
224
231
|
});
|
|
225
232
|
pageElement.appendChild(textLayer);
|
|
226
|
-
})
|
|
227
|
-
.catch(error);
|
|
233
|
+
}).catch(error);
|
|
228
234
|
});
|
|
229
235
|
})
|
|
230
236
|
.catch(error);
|
package/dist/es2015/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { saveAs } from '@progress/kendo-file-saver';
|
|
2
2
|
import { detectDesktopBrowser, detectMobileOS } from '@progress/kendo-common';
|
|
3
|
-
import { getDocument,
|
|
3
|
+
import { getDocument, TextLayer } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
4
4
|
const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
|
|
5
5
|
const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
|
|
6
6
|
const MAX_CANVAS_WIDTH_HEIGHT_FIREFOX = 32767;
|
|
@@ -91,14 +91,23 @@ export const loadPDF = (options) => {
|
|
|
91
91
|
pages.push(pdfDoc.getPage(i));
|
|
92
92
|
}
|
|
93
93
|
return { pages, pdfDoc };
|
|
94
|
-
})
|
|
95
|
-
.then(({ pages, pdfDoc }) => {
|
|
94
|
+
}).then(({ pages, pdfDoc }) => {
|
|
96
95
|
Promise.all(pages)
|
|
97
96
|
.then((all) => all.map((page, i) => {
|
|
98
97
|
appendPage(dom, renderPage(page, zoom, error), i);
|
|
99
98
|
return page;
|
|
100
|
-
}))
|
|
101
|
-
|
|
99
|
+
})).then((pdfPages) => {
|
|
100
|
+
// required by new PDFJS version
|
|
101
|
+
const sheet = new CSSStyleSheet();
|
|
102
|
+
sheet.replaceSync(`.hiddenCanvasElement {
|
|
103
|
+
position: absolute;
|
|
104
|
+
top: 0;
|
|
105
|
+
left: 0;
|
|
106
|
+
width: 0;
|
|
107
|
+
height: 0;
|
|
108
|
+
display: none;
|
|
109
|
+
}`);
|
|
110
|
+
options.dom.ownerDocument.adoptedStyleSheets = [sheet];
|
|
102
111
|
done({ pdfPages, pdfDoc, zoom });
|
|
103
112
|
})
|
|
104
113
|
.catch((reason) => {
|
|
@@ -203,13 +212,11 @@ const renderPage = (page, zoom, error) => {
|
|
|
203
212
|
.promise.then(() => {
|
|
204
213
|
page.getTextContent().then((textContent) => {
|
|
205
214
|
const textLayer = createElement('div', 'k-text-layer', styles);
|
|
206
|
-
|
|
215
|
+
new TextLayer({
|
|
207
216
|
textContentSource: textContent,
|
|
208
217
|
container: textLayer,
|
|
209
|
-
viewport: viewport
|
|
210
|
-
|
|
211
|
-
})
|
|
212
|
-
.promise.then(() => {
|
|
218
|
+
viewport: viewport
|
|
219
|
+
}).render().then(() => {
|
|
213
220
|
textLayer.style.width = textLayer.style.width.replace(/px/g, 'pt');
|
|
214
221
|
textLayer.style.height = textLayer.style.height.replace(/px/g, 'pt');
|
|
215
222
|
const rotation = textLayer.getAttribute('data-main-rotation') || '0';
|
|
@@ -223,8 +230,7 @@ const renderPage = (page, zoom, error) => {
|
|
|
223
230
|
}
|
|
224
231
|
});
|
|
225
232
|
pageElement.appendChild(textLayer);
|
|
226
|
-
})
|
|
227
|
-
.catch(error);
|
|
233
|
+
}).catch(error);
|
|
228
234
|
});
|
|
229
235
|
})
|
|
230
236
|
.catch(error);
|
package/dist/npm/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SaveOptions } from '@progress/kendo-file-saver';
|
|
2
|
-
import { PDFPageProxy, PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
import { PDFPageProxy, PDFDocumentProxy } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
3
3
|
import { TypedArray } from 'pdfjs-dist/types/src/display/api';
|
|
4
4
|
/**
|
|
5
5
|
* @hidden
|
package/dist/npm/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.currentPage = exports.scrollToPage = exports.calculateZoomLevel = exports.goToPreviousSearchMatch = exports.goToNextSearchMatch = exports.print = exports.reloadDocument = exports.loadPDF = exports.download = exports.removeChildren = 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
|
-
const
|
|
6
|
+
const pdf_mjs_1 = require("pdfjs-dist/legacy/build/pdf.mjs");
|
|
7
7
|
const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
|
|
8
8
|
const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
|
|
9
9
|
const MAX_CANVAS_WIDTH_HEIGHT_FIREFOX = 32767;
|
|
@@ -89,21 +89,30 @@ exports.download = download;
|
|
|
89
89
|
const loadPDF = (options) => {
|
|
90
90
|
const params = getDocumentParameters(options);
|
|
91
91
|
const { dom, zoom, done, error } = options;
|
|
92
|
-
(0,
|
|
92
|
+
(0, pdf_mjs_1.getDocument)(params)
|
|
93
93
|
.promise.then((pdfDoc) => {
|
|
94
94
|
const pages = [];
|
|
95
95
|
for (let i = 1; i <= pdfDoc.numPages; i++) {
|
|
96
96
|
pages.push(pdfDoc.getPage(i));
|
|
97
97
|
}
|
|
98
98
|
return { pages, pdfDoc };
|
|
99
|
-
})
|
|
100
|
-
.then(({ pages, pdfDoc }) => {
|
|
99
|
+
}).then(({ pages, pdfDoc }) => {
|
|
101
100
|
Promise.all(pages)
|
|
102
101
|
.then((all) => all.map((page, i) => {
|
|
103
102
|
appendPage(dom, renderPage(page, zoom, error), i);
|
|
104
103
|
return page;
|
|
105
|
-
}))
|
|
106
|
-
|
|
104
|
+
})).then((pdfPages) => {
|
|
105
|
+
// required by new PDFJS version
|
|
106
|
+
const sheet = new CSSStyleSheet();
|
|
107
|
+
sheet.replaceSync(`.hiddenCanvasElement {
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 0;
|
|
110
|
+
left: 0;
|
|
111
|
+
width: 0;
|
|
112
|
+
height: 0;
|
|
113
|
+
display: none;
|
|
114
|
+
}`);
|
|
115
|
+
options.dom.ownerDocument.adoptedStyleSheets = [sheet];
|
|
107
116
|
done({ pdfPages, pdfDoc, zoom });
|
|
108
117
|
})
|
|
109
118
|
.catch((reason) => {
|
|
@@ -211,13 +220,11 @@ const renderPage = (page, zoom, error) => {
|
|
|
211
220
|
.promise.then(() => {
|
|
212
221
|
page.getTextContent().then((textContent) => {
|
|
213
222
|
const textLayer = createElement('div', 'k-text-layer', styles);
|
|
214
|
-
|
|
223
|
+
new pdf_mjs_1.TextLayer({
|
|
215
224
|
textContentSource: textContent,
|
|
216
225
|
container: textLayer,
|
|
217
|
-
viewport: viewport
|
|
218
|
-
|
|
219
|
-
})
|
|
220
|
-
.promise.then(() => {
|
|
226
|
+
viewport: viewport
|
|
227
|
+
}).render().then(() => {
|
|
221
228
|
textLayer.style.width = textLayer.style.width.replace(/px/g, 'pt');
|
|
222
229
|
textLayer.style.height = textLayer.style.height.replace(/px/g, 'pt');
|
|
223
230
|
const rotation = textLayer.getAttribute('data-main-rotation') || '0';
|
|
@@ -231,8 +238,7 @@ const renderPage = (page, zoom, error) => {
|
|
|
231
238
|
}
|
|
232
239
|
});
|
|
233
240
|
pageElement.appendChild(textLayer);
|
|
234
|
-
})
|
|
235
|
-
.catch(error);
|
|
241
|
+
}).catch(error);
|
|
236
242
|
});
|
|
237
243
|
})
|
|
238
244
|
.catch(error);
|
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.2.
|
|
4
|
+
"version": "0.2.11-dev.202408260632",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Kendo UI"
|
|
7
7
|
],
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@progress/kendo-common": "^0.2.2",
|
|
29
|
-
"pdfjs-dist": "^3.
|
|
29
|
+
"pdfjs-dist": "^4.3.136",
|
|
30
30
|
"tslib": "^2.4.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|