@progress/kendo-pdfviewer-common 0.3.2 → 0.3.3-dev.202410171248
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 +26 -29
- package/dist/es2015/utils.js +26 -29
- package/dist/npm/utils.d.ts +0 -2
- package/dist/npm/utils.js +26 -29
- package/package.json +1 -1
package/dist/es/utils.js
CHANGED
|
@@ -84,7 +84,7 @@ export const download = (options, fileName = 'Document', saveOptions = {}, onDow
|
|
|
84
84
|
*/
|
|
85
85
|
export const loadPDF = (options) => {
|
|
86
86
|
const params = getDocumentParameters(options);
|
|
87
|
-
const { dom, zoom, done, error, rootElement
|
|
87
|
+
const { dom, zoom, done, error, rootElement } = options;
|
|
88
88
|
const loadOnDemandPageSize = options.loadOnDemandPageSize || 2;
|
|
89
89
|
getDocument(params)
|
|
90
90
|
.promise.then((pdfDoc) => {
|
|
@@ -96,7 +96,7 @@ export const loadPDF = (options) => {
|
|
|
96
96
|
}).then(({ pages, pdfDoc }) => {
|
|
97
97
|
Promise.all(pages)
|
|
98
98
|
.then((all) => all.map((page, i) => {
|
|
99
|
-
const emptyPage = createEmptyPage(page, zoom, pdfDoc,
|
|
99
|
+
const emptyPage = createEmptyPage(page, zoom, pdfDoc, rootElement);
|
|
100
100
|
appendPage(dom, emptyPage.pageElement, i);
|
|
101
101
|
if (options.loadOnDemand) {
|
|
102
102
|
// If LOD is enabled, render the first two(default) or X pages initially.
|
|
@@ -135,7 +135,7 @@ export const loadPDF = (options) => {
|
|
|
135
135
|
* @hidden
|
|
136
136
|
*/
|
|
137
137
|
export const reloadDocument = (params) => {
|
|
138
|
-
const { pdfDoc, zoom, dom, done, error, loadOnDemand, rootElement
|
|
138
|
+
const { pdfDoc, zoom, dom, done, error, loadOnDemand, rootElement } = params;
|
|
139
139
|
const pages = [];
|
|
140
140
|
let currentPageIndex = 0;
|
|
141
141
|
// Save the index of the current page in view before we reload the document.
|
|
@@ -149,7 +149,7 @@ export const reloadDocument = (params) => {
|
|
|
149
149
|
.then((all) => all.map((page, i) => {
|
|
150
150
|
// Set 'rendered' back to false so that the pages can be re-rendered when scrolling.
|
|
151
151
|
page._pageInfo.rendered = false;
|
|
152
|
-
const emptyPage = createEmptyPage(page, zoom, pdfDoc,
|
|
152
|
+
const emptyPage = createEmptyPage(page, zoom, pdfDoc, rootElement);
|
|
153
153
|
appendPage(dom, emptyPage.pageElement, i);
|
|
154
154
|
// If on demand is not enabled, proceed as usual.
|
|
155
155
|
if (!loadOnDemand) {
|
|
@@ -212,7 +212,7 @@ const openPrintDialog = (dom, width, height, done, onError) => {
|
|
|
212
212
|
printDialog.addEventListener('afterprint', onAfterPrint);
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
|
-
const createEmptyPage = (page, zoom, pdfDoc,
|
|
215
|
+
const createEmptyPage = (page, zoom, pdfDoc, rootElement) => {
|
|
216
216
|
const { canvasContext, viewport, pageElement, styles } = createCanvas(page, zoom, 'k-page');
|
|
217
217
|
return {
|
|
218
218
|
canvasContext,
|
|
@@ -221,7 +221,6 @@ const createEmptyPage = (page, zoom, pdfDoc, enableAnnotations, rootElement) =>
|
|
|
221
221
|
styles,
|
|
222
222
|
zoom,
|
|
223
223
|
pdfDoc,
|
|
224
|
-
enableAnnotations,
|
|
225
224
|
rootElement
|
|
226
225
|
};
|
|
227
226
|
};
|
|
@@ -255,7 +254,7 @@ export const transforms = {
|
|
|
255
254
|
'270': 'rotate(270deg) translateX(-100%)'
|
|
256
255
|
};
|
|
257
256
|
export const renderPage = (page, emptyPage, error) => {
|
|
258
|
-
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc,
|
|
257
|
+
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement } = emptyPage;
|
|
259
258
|
page._pageInfo.renderInProgress = true;
|
|
260
259
|
page.render({ canvasContext, viewport })
|
|
261
260
|
.promise.then(() => {
|
|
@@ -281,29 +280,27 @@ export const renderPage = (page, emptyPage, error) => {
|
|
|
281
280
|
pageElement.prepend(textLayer); // Use prepend to ensure the element is always inserted before the annotation layer.
|
|
282
281
|
}).catch(error);
|
|
283
282
|
});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
pointerEvents: 'none'
|
|
294
|
-
});
|
|
295
|
-
pageElement.appendChild(annotationLayer);
|
|
296
|
-
for (const annotation of annotations) {
|
|
297
|
-
switch (annotation.subtype) {
|
|
298
|
-
case 'Link':
|
|
299
|
-
new LinkAnnotation(annotationLayer, viewport, annotation, pdfDoc, zoom, rootElement);
|
|
300
|
-
break;
|
|
301
|
-
default:
|
|
302
|
-
null;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
283
|
+
page.getAnnotations({ intent: 'display' }).then((annotations) => {
|
|
284
|
+
const annotationLayer = createElement('div', 'k-annotations-layer', {
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
top: '0',
|
|
287
|
+
left: '0',
|
|
288
|
+
overflow: 'hidden',
|
|
289
|
+
height: styles.height,
|
|
290
|
+
width: styles.width,
|
|
291
|
+
pointerEvents: 'none'
|
|
305
292
|
});
|
|
306
|
-
|
|
293
|
+
pageElement.appendChild(annotationLayer);
|
|
294
|
+
for (const annotation of annotations) {
|
|
295
|
+
switch (annotation.subtype) {
|
|
296
|
+
case 'Link':
|
|
297
|
+
new LinkAnnotation(annotationLayer, viewport, annotation, pdfDoc, zoom, rootElement);
|
|
298
|
+
break;
|
|
299
|
+
default:
|
|
300
|
+
null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
307
304
|
})
|
|
308
305
|
.then(() => {
|
|
309
306
|
page._pageInfo.rendered = true;
|
package/dist/es2015/utils.js
CHANGED
|
@@ -84,7 +84,7 @@ export const download = (options, fileName = 'Document', saveOptions = {}, onDow
|
|
|
84
84
|
*/
|
|
85
85
|
export const loadPDF = (options) => {
|
|
86
86
|
const params = getDocumentParameters(options);
|
|
87
|
-
const { dom, zoom, done, error, rootElement
|
|
87
|
+
const { dom, zoom, done, error, rootElement } = options;
|
|
88
88
|
const loadOnDemandPageSize = options.loadOnDemandPageSize || 2;
|
|
89
89
|
getDocument(params)
|
|
90
90
|
.promise.then((pdfDoc) => {
|
|
@@ -96,7 +96,7 @@ export const loadPDF = (options) => {
|
|
|
96
96
|
}).then(({ pages, pdfDoc }) => {
|
|
97
97
|
Promise.all(pages)
|
|
98
98
|
.then((all) => all.map((page, i) => {
|
|
99
|
-
const emptyPage = createEmptyPage(page, zoom, pdfDoc,
|
|
99
|
+
const emptyPage = createEmptyPage(page, zoom, pdfDoc, rootElement);
|
|
100
100
|
appendPage(dom, emptyPage.pageElement, i);
|
|
101
101
|
if (options.loadOnDemand) {
|
|
102
102
|
// If LOD is enabled, render the first two(default) or X pages initially.
|
|
@@ -135,7 +135,7 @@ export const loadPDF = (options) => {
|
|
|
135
135
|
* @hidden
|
|
136
136
|
*/
|
|
137
137
|
export const reloadDocument = (params) => {
|
|
138
|
-
const { pdfDoc, zoom, dom, done, error, loadOnDemand, rootElement
|
|
138
|
+
const { pdfDoc, zoom, dom, done, error, loadOnDemand, rootElement } = params;
|
|
139
139
|
const pages = [];
|
|
140
140
|
let currentPageIndex = 0;
|
|
141
141
|
// Save the index of the current page in view before we reload the document.
|
|
@@ -149,7 +149,7 @@ export const reloadDocument = (params) => {
|
|
|
149
149
|
.then((all) => all.map((page, i) => {
|
|
150
150
|
// Set 'rendered' back to false so that the pages can be re-rendered when scrolling.
|
|
151
151
|
page._pageInfo.rendered = false;
|
|
152
|
-
const emptyPage = createEmptyPage(page, zoom, pdfDoc,
|
|
152
|
+
const emptyPage = createEmptyPage(page, zoom, pdfDoc, rootElement);
|
|
153
153
|
appendPage(dom, emptyPage.pageElement, i);
|
|
154
154
|
// If on demand is not enabled, proceed as usual.
|
|
155
155
|
if (!loadOnDemand) {
|
|
@@ -212,7 +212,7 @@ const openPrintDialog = (dom, width, height, done, onError) => {
|
|
|
212
212
|
printDialog.addEventListener('afterprint', onAfterPrint);
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
|
-
const createEmptyPage = (page, zoom, pdfDoc,
|
|
215
|
+
const createEmptyPage = (page, zoom, pdfDoc, rootElement) => {
|
|
216
216
|
const { canvasContext, viewport, pageElement, styles } = createCanvas(page, zoom, 'k-page');
|
|
217
217
|
return {
|
|
218
218
|
canvasContext,
|
|
@@ -221,7 +221,6 @@ const createEmptyPage = (page, zoom, pdfDoc, enableAnnotations, rootElement) =>
|
|
|
221
221
|
styles,
|
|
222
222
|
zoom,
|
|
223
223
|
pdfDoc,
|
|
224
|
-
enableAnnotations,
|
|
225
224
|
rootElement
|
|
226
225
|
};
|
|
227
226
|
};
|
|
@@ -255,7 +254,7 @@ export const transforms = {
|
|
|
255
254
|
'270': 'rotate(270deg) translateX(-100%)'
|
|
256
255
|
};
|
|
257
256
|
export const renderPage = (page, emptyPage, error) => {
|
|
258
|
-
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc,
|
|
257
|
+
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement } = emptyPage;
|
|
259
258
|
page._pageInfo.renderInProgress = true;
|
|
260
259
|
page.render({ canvasContext, viewport })
|
|
261
260
|
.promise.then(() => {
|
|
@@ -281,29 +280,27 @@ export const renderPage = (page, emptyPage, error) => {
|
|
|
281
280
|
pageElement.prepend(textLayer); // Use prepend to ensure the element is always inserted before the annotation layer.
|
|
282
281
|
}).catch(error);
|
|
283
282
|
});
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
pointerEvents: 'none'
|
|
294
|
-
});
|
|
295
|
-
pageElement.appendChild(annotationLayer);
|
|
296
|
-
for (const annotation of annotations) {
|
|
297
|
-
switch (annotation.subtype) {
|
|
298
|
-
case 'Link':
|
|
299
|
-
new LinkAnnotation(annotationLayer, viewport, annotation, pdfDoc, zoom, rootElement);
|
|
300
|
-
break;
|
|
301
|
-
default:
|
|
302
|
-
null;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
283
|
+
page.getAnnotations({ intent: 'display' }).then((annotations) => {
|
|
284
|
+
const annotationLayer = createElement('div', 'k-annotations-layer', {
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
top: '0',
|
|
287
|
+
left: '0',
|
|
288
|
+
overflow: 'hidden',
|
|
289
|
+
height: styles.height,
|
|
290
|
+
width: styles.width,
|
|
291
|
+
pointerEvents: 'none'
|
|
305
292
|
});
|
|
306
|
-
|
|
293
|
+
pageElement.appendChild(annotationLayer);
|
|
294
|
+
for (const annotation of annotations) {
|
|
295
|
+
switch (annotation.subtype) {
|
|
296
|
+
case 'Link':
|
|
297
|
+
new LinkAnnotation(annotationLayer, viewport, annotation, pdfDoc, zoom, rootElement);
|
|
298
|
+
break;
|
|
299
|
+
default:
|
|
300
|
+
null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
307
304
|
})
|
|
308
305
|
.then(() => {
|
|
309
306
|
page._pageInfo.rendered = true;
|
package/dist/npm/utils.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface PDFReadOptions extends PDFReadParameters {
|
|
|
32
32
|
rootElement?: HTMLElement | null;
|
|
33
33
|
dom: HTMLDivElement;
|
|
34
34
|
zoom: number;
|
|
35
|
-
enableAnnotations: boolean;
|
|
36
35
|
done: DoneFn;
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
@@ -46,7 +45,6 @@ export interface PDFReloadParameters {
|
|
|
46
45
|
loadOnDemand?: boolean;
|
|
47
46
|
done: (pdfPages: PDFPageProxy[]) => void;
|
|
48
47
|
error: ErrorFn;
|
|
49
|
-
enableAnnotations: boolean;
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
52
50
|
* @hidden
|
package/dist/npm/utils.js
CHANGED
|
@@ -91,7 +91,7 @@ exports.download = download;
|
|
|
91
91
|
*/
|
|
92
92
|
const loadPDF = (options) => {
|
|
93
93
|
const params = getDocumentParameters(options);
|
|
94
|
-
const { dom, zoom, done, error, rootElement
|
|
94
|
+
const { dom, zoom, done, error, rootElement } = options;
|
|
95
95
|
const loadOnDemandPageSize = options.loadOnDemandPageSize || 2;
|
|
96
96
|
(0, pdf_mjs_1.getDocument)(params)
|
|
97
97
|
.promise.then((pdfDoc) => {
|
|
@@ -103,7 +103,7 @@ const loadPDF = (options) => {
|
|
|
103
103
|
}).then(({ pages, pdfDoc }) => {
|
|
104
104
|
Promise.all(pages)
|
|
105
105
|
.then((all) => all.map((page, i) => {
|
|
106
|
-
const emptyPage = createEmptyPage(page, zoom, pdfDoc,
|
|
106
|
+
const emptyPage = createEmptyPage(page, zoom, pdfDoc, rootElement);
|
|
107
107
|
appendPage(dom, emptyPage.pageElement, i);
|
|
108
108
|
if (options.loadOnDemand) {
|
|
109
109
|
// If LOD is enabled, render the first two(default) or X pages initially.
|
|
@@ -143,7 +143,7 @@ exports.loadPDF = loadPDF;
|
|
|
143
143
|
* @hidden
|
|
144
144
|
*/
|
|
145
145
|
const reloadDocument = (params) => {
|
|
146
|
-
const { pdfDoc, zoom, dom, done, error, loadOnDemand, rootElement
|
|
146
|
+
const { pdfDoc, zoom, dom, done, error, loadOnDemand, rootElement } = params;
|
|
147
147
|
const pages = [];
|
|
148
148
|
let currentPageIndex = 0;
|
|
149
149
|
// Save the index of the current page in view before we reload the document.
|
|
@@ -157,7 +157,7 @@ const reloadDocument = (params) => {
|
|
|
157
157
|
.then((all) => all.map((page, i) => {
|
|
158
158
|
// Set 'rendered' back to false so that the pages can be re-rendered when scrolling.
|
|
159
159
|
page._pageInfo.rendered = false;
|
|
160
|
-
const emptyPage = createEmptyPage(page, zoom, pdfDoc,
|
|
160
|
+
const emptyPage = createEmptyPage(page, zoom, pdfDoc, rootElement);
|
|
161
161
|
appendPage(dom, emptyPage.pageElement, i);
|
|
162
162
|
// If on demand is not enabled, proceed as usual.
|
|
163
163
|
if (!loadOnDemand) {
|
|
@@ -222,7 +222,7 @@ const openPrintDialog = (dom, width, height, done, onError) => {
|
|
|
222
222
|
printDialog.addEventListener('afterprint', onAfterPrint);
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
|
-
const createEmptyPage = (page, zoom, pdfDoc,
|
|
225
|
+
const createEmptyPage = (page, zoom, pdfDoc, rootElement) => {
|
|
226
226
|
const { canvasContext, viewport, pageElement, styles } = createCanvas(page, zoom, 'k-page');
|
|
227
227
|
return {
|
|
228
228
|
canvasContext,
|
|
@@ -231,7 +231,6 @@ const createEmptyPage = (page, zoom, pdfDoc, enableAnnotations, rootElement) =>
|
|
|
231
231
|
styles,
|
|
232
232
|
zoom,
|
|
233
233
|
pdfDoc,
|
|
234
|
-
enableAnnotations,
|
|
235
234
|
rootElement
|
|
236
235
|
};
|
|
237
236
|
};
|
|
@@ -266,7 +265,7 @@ exports.transforms = {
|
|
|
266
265
|
'270': 'rotate(270deg) translateX(-100%)'
|
|
267
266
|
};
|
|
268
267
|
const renderPage = (page, emptyPage, error) => {
|
|
269
|
-
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc,
|
|
268
|
+
const { canvasContext, viewport, pageElement, styles, zoom, pdfDoc, rootElement } = emptyPage;
|
|
270
269
|
page._pageInfo.renderInProgress = true;
|
|
271
270
|
page.render({ canvasContext, viewport })
|
|
272
271
|
.promise.then(() => {
|
|
@@ -292,29 +291,27 @@ const renderPage = (page, emptyPage, error) => {
|
|
|
292
291
|
pageElement.prepend(textLayer); // Use prepend to ensure the element is always inserted before the annotation layer.
|
|
293
292
|
}).catch(error);
|
|
294
293
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
pointerEvents: 'none'
|
|
305
|
-
});
|
|
306
|
-
pageElement.appendChild(annotationLayer);
|
|
307
|
-
for (const annotation of annotations) {
|
|
308
|
-
switch (annotation.subtype) {
|
|
309
|
-
case 'Link':
|
|
310
|
-
new annotations_1.LinkAnnotation(annotationLayer, viewport, annotation, pdfDoc, zoom, rootElement);
|
|
311
|
-
break;
|
|
312
|
-
default:
|
|
313
|
-
null;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
294
|
+
page.getAnnotations({ intent: 'display' }).then((annotations) => {
|
|
295
|
+
const annotationLayer = (0, exports.createElement)('div', 'k-annotations-layer', {
|
|
296
|
+
position: 'absolute',
|
|
297
|
+
top: '0',
|
|
298
|
+
left: '0',
|
|
299
|
+
overflow: 'hidden',
|
|
300
|
+
height: styles.height,
|
|
301
|
+
width: styles.width,
|
|
302
|
+
pointerEvents: 'none'
|
|
316
303
|
});
|
|
317
|
-
|
|
304
|
+
pageElement.appendChild(annotationLayer);
|
|
305
|
+
for (const annotation of annotations) {
|
|
306
|
+
switch (annotation.subtype) {
|
|
307
|
+
case 'Link':
|
|
308
|
+
new annotations_1.LinkAnnotation(annotationLayer, viewport, annotation, pdfDoc, zoom, rootElement);
|
|
309
|
+
break;
|
|
310
|
+
default:
|
|
311
|
+
null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
318
315
|
})
|
|
319
316
|
.then(() => {
|
|
320
317
|
page._pageInfo.rendered = true;
|