-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (40 loc) · 1.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
window.addEventListener('load', async () => {
const response = await fetch('prcm.pdf');
const arrayBuffer = await response.arrayBuffer();
const document = await pdfjsLib.getDocument(arrayBuffer).promise;
const pageCount = document.numPages;
for (let pageNumber = 1; pageNumber <= pageCount; pageNumber++) {
console.log(`Page #${pageNumber}`);
const page = await document.getPage(pageNumber);
const canvas = window.document.createElement('canvas');
const context = canvas.getContext('2d');
const viewport = page.getViewport(1);
await page.render({
canvasContext: context,
viewport,
textLayer: {
beginLayout(...args) {
console.log('text layer being layout', args);
},
endLayout(...args) {
console.log('text layer end layout', args);
},
appendText(...args) {
console.log('text layer append text', args);
},
},
imageLayer: {
beginLayout() {
console.log('image layer being layout');
},
endLayout() {
console.log('image layer end layout');
},
appendImage(...args) {
console.log('image layer append image', args);
},
},
}).promise;
break;
}
});