@vaadin-component-factory/vcf-pdf-viewer 3.0.2 → 3.2.0
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/package.json +22 -16
- package/pdfjs/dist/event_utils.js +207 -0
- package/pdfjs/dist/genericl10n.js +2395 -0
- package/pdfjs/dist/message_handler.js +325 -190
- package/pdfjs/dist/node_stream.js +2 -494
- package/pdfjs/dist/node_stream2.js +1754 -0
- package/pdfjs/dist/pdf.js +19294 -11168
- package/pdfjs/dist/pdf.worker.js +23 -0
- package/pdfjs/dist/pdf_link_service.js +222 -378
- package/pdfjs/dist/pdf_rendering_queue.js +61 -62
- package/pdfjs/dist/pdf_thumbnail_viewer.js +214 -399
- package/pdfjs/dist/pdf_viewer.js +3432 -2295
- package/pdfjs/dist/ui_utils.js +209 -480
- package/pdfjs/dist/util.js +382 -568
- package/pdfjs/dist/worker.js +41580 -42492
- package/src/vcf-pdf-viewer.js +175 -19
package/src/vcf-pdf-viewer.js
CHANGED
|
@@ -12,13 +12,14 @@ import '@vaadin/tooltip';
|
|
|
12
12
|
|
|
13
13
|
import * as pdfjsLib from '../pdfjs/dist/pdf';
|
|
14
14
|
import * as pdfjsViewer from '../pdfjs/dist/pdf_viewer';
|
|
15
|
-
import * as pdfUtils from '../pdfjs/dist/ui_utils'
|
|
15
|
+
import * as pdfUtils from '../pdfjs/dist/ui_utils';
|
|
16
|
+
import { EventBus } from "../pdfjs/dist/event_utils";
|
|
16
17
|
import * as pdfjsLinkService from '../pdfjs/dist/pdf_link_service';
|
|
17
18
|
import * as pdfjsThumbnailViewer from '../pdfjs/dist/pdf_thumbnail_viewer';
|
|
18
19
|
import * as pdfjsRenderingQueue from '../pdfjs/dist/pdf_rendering_queue';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
pdfjsLib.GlobalWorkerOptions.workerSrc =
|
|
20
|
+
import { GenericL10n } from "../pdfjs/dist/genericl10n";
|
|
21
|
+
|
|
22
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = "../pdfjs/dist/worker.js";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* `<vcf-pdf-viewer>` is a Web Component for rendering PDF files without
|
|
@@ -45,7 +46,8 @@ class PdfViewerElement extends
|
|
|
45
46
|
display: flex;
|
|
46
47
|
flex-direction: column;
|
|
47
48
|
width: 100%;
|
|
48
|
-
height: 500px;
|
|
49
|
+
height: 500px;
|
|
50
|
+
--pdf-viewer-link-hover-color: rgb(255 255 0);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
:host([hidden]) {
|
|
@@ -119,7 +121,6 @@ class PdfViewerElement extends
|
|
|
119
121
|
|
|
120
122
|
[part~="thumbnail-view"] {
|
|
121
123
|
position: absolute;
|
|
122
|
-
width: calc(100% - 60px);
|
|
123
124
|
top: 0;
|
|
124
125
|
bottom: 0;
|
|
125
126
|
padding: 10px 30px 0;
|
|
@@ -135,6 +136,14 @@ class PdfViewerElement extends
|
|
|
135
136
|
margin: 0 auto;
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
.canvasWrapper {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 0;
|
|
142
|
+
left: 0;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: 100%;
|
|
145
|
+
}
|
|
146
|
+
|
|
138
147
|
.textLayer {
|
|
139
148
|
position: absolute;
|
|
140
149
|
left: 0;
|
|
@@ -213,7 +222,8 @@ class PdfViewerElement extends
|
|
|
213
222
|
}
|
|
214
223
|
|
|
215
224
|
.thumbnail {
|
|
216
|
-
margin:
|
|
225
|
+
margin: 5px;
|
|
226
|
+
padding: 7px 7px 3px 7px;
|
|
217
227
|
}
|
|
218
228
|
|
|
219
229
|
.thumbnailImage {
|
|
@@ -224,13 +234,8 @@ class PdfViewerElement extends
|
|
|
224
234
|
background-color: rgba(255, 255, 255, 1);
|
|
225
235
|
background-clip: content-box;
|
|
226
236
|
}
|
|
227
|
-
|
|
228
|
-
.
|
|
229
|
-
border-radius: 2px;
|
|
230
|
-
padding: 7px;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.thumbnail.selected > .thumbnailSelectionRing {
|
|
237
|
+
|
|
238
|
+
.thumbnail.selected {
|
|
234
239
|
background-color: rgba(0, 0, 0, 0.15);
|
|
235
240
|
}
|
|
236
241
|
|
|
@@ -251,6 +256,133 @@ class PdfViewerElement extends
|
|
|
251
256
|
display: none;
|
|
252
257
|
}
|
|
253
258
|
|
|
259
|
+
/* Annotation layer */
|
|
260
|
+
|
|
261
|
+
.annotationLayer {
|
|
262
|
+
--annotation-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width='1px' height='1px' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' style='fill:rgba(0, 54, 255, 0.13);'/></svg>");
|
|
263
|
+
--input-focus-border-color: Highlight;
|
|
264
|
+
--input-focus-outline: 1px solid Canvas;
|
|
265
|
+
--input-unfocused-border-color: transparent;
|
|
266
|
+
--input-disabled-border-color: transparent;
|
|
267
|
+
--input-hover-border-color: black;
|
|
268
|
+
--link-outline: none;
|
|
269
|
+
position: absolute;
|
|
270
|
+
top: 0;
|
|
271
|
+
left: 0;
|
|
272
|
+
pointer-events: none;
|
|
273
|
+
transform-origin: 0 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.annotationLayer section {
|
|
277
|
+
position: absolute;
|
|
278
|
+
text-align: initial;
|
|
279
|
+
pointer-events: auto;
|
|
280
|
+
box-sizing: border-box;
|
|
281
|
+
transform-origin: 0 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) > a {
|
|
285
|
+
position: absolute;
|
|
286
|
+
font-size: 1em;
|
|
287
|
+
top: 0;
|
|
288
|
+
left: 0;
|
|
289
|
+
width: 100%;
|
|
290
|
+
height: 100%;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton):not(.hasBorder) > a:hover {
|
|
294
|
+
opacity: 0.2;
|
|
295
|
+
background-color: var(--pdf-viewer-link-hover-color);
|
|
296
|
+
box-shadow: 0 2px 10px var(--pdf-viewer-link-hover-color);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.annotationLayer .linkAnnotation.hasBorder:hover {
|
|
300
|
+
background-color: color-mix(in srgb, var(--pdf-viewer-link-hover-color) 20%, transparent);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.annotationLayer .hasBorder {
|
|
304
|
+
background-size: 100% 100%;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea),
|
|
308
|
+
.annotationLayer .choiceWidgetAnnotation select,
|
|
309
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
|
|
310
|
+
background-image: var(--annotation-unfocused-field-background);
|
|
311
|
+
border: 2px solid var(--input-unfocused-border-color);
|
|
312
|
+
box-sizing: border-box;
|
|
313
|
+
font: calc(9px * var(--scale-factor)) sans-serif;
|
|
314
|
+
height: 100%;
|
|
315
|
+
margin: 0;
|
|
316
|
+
vertical-align: top;
|
|
317
|
+
width: 100%;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea):hover,
|
|
321
|
+
.annotationLayer .choiceWidgetAnnotation select:hover,
|
|
322
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input:hover {
|
|
323
|
+
border: 2px solid var(--input-hover-border-color);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea):focus,
|
|
327
|
+
.annotationLayer .choiceWidgetAnnotation select:focus {
|
|
328
|
+
background: none;
|
|
329
|
+
border: 2px solid var(--input-focus-border-color);
|
|
330
|
+
border-radius: 2px;
|
|
331
|
+
outline: var(--input-focus-outline);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.annotationLayer .buttonWidgetAnnotation.radioButton input {
|
|
335
|
+
border-radius: 50%;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.annotationLayer .textWidgetAnnotation textarea {
|
|
339
|
+
resize: none;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
|
|
343
|
+
appearance: none;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before,
|
|
347
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after,
|
|
348
|
+
.annotationLayer .buttonWidgetAnnotation.radioButton input:checked::before {
|
|
349
|
+
background-color: CanvasText;
|
|
350
|
+
content: "";
|
|
351
|
+
display: block;
|
|
352
|
+
position: absolute;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before,
|
|
356
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after {
|
|
357
|
+
height: 80%;
|
|
358
|
+
left: 45%;
|
|
359
|
+
width: 1px;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before {
|
|
363
|
+
transform: rotate(45deg);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after {
|
|
367
|
+
transform: rotate(-45deg);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.annotationLayer .buttonWidgetAnnotation.radioButton input:checked::before {
|
|
371
|
+
border-radius: 50%;
|
|
372
|
+
height: 50%;
|
|
373
|
+
left: 25%;
|
|
374
|
+
top: 25%;
|
|
375
|
+
width: 50%;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea)[disabled],
|
|
379
|
+
.annotationLayer .choiceWidgetAnnotation select[disabled],
|
|
380
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input[disabled] {
|
|
381
|
+
background: none;
|
|
382
|
+
border: 2px solid var(--input-disabled-border-color);
|
|
383
|
+
cursor: not-allowed;
|
|
384
|
+
}
|
|
385
|
+
|
|
254
386
|
</style>
|
|
255
387
|
|
|
256
388
|
<div id="outerContainer" part="outer-container" >
|
|
@@ -287,7 +419,7 @@ class PdfViewerElement extends
|
|
|
287
419
|
}
|
|
288
420
|
|
|
289
421
|
static get version() {
|
|
290
|
-
return '3.0
|
|
422
|
+
return '3.2.0';
|
|
291
423
|
}
|
|
292
424
|
|
|
293
425
|
static get properties() {
|
|
@@ -602,6 +734,10 @@ class PdfViewerElement extends
|
|
|
602
734
|
ready() {
|
|
603
735
|
super.ready();
|
|
604
736
|
|
|
737
|
+
// Required by PDF.js annotation editor: --freetext-line-height must match
|
|
738
|
+
// the LINE_FACTOR constant (1.35) defined in src/shared/util.js
|
|
739
|
+
document.documentElement.style.setProperty('--freetext-line-height', '1.35');
|
|
740
|
+
|
|
605
741
|
this._addToolbarButtons();
|
|
606
742
|
|
|
607
743
|
this.$.viewerContainer.addEventListener('focus', e => this.__setFocused(true), true);
|
|
@@ -616,12 +752,12 @@ class PdfViewerElement extends
|
|
|
616
752
|
});
|
|
617
753
|
|
|
618
754
|
// options
|
|
619
|
-
const eventBus = new
|
|
755
|
+
const eventBus = new EventBus();
|
|
620
756
|
this.__linkService = new pdfjsLinkService.PDFLinkService({
|
|
621
757
|
eventBus,
|
|
622
758
|
});
|
|
623
759
|
var pdfRenderingQueue = new pdfjsRenderingQueue.PDFRenderingQueue();
|
|
624
|
-
var l10n =
|
|
760
|
+
var l10n = new GenericL10n(navigator.language || 'en-US');
|
|
625
761
|
|
|
626
762
|
// pdfViewer
|
|
627
763
|
this.__viewer = new pdfjsViewer.PDFViewer({
|
|
@@ -632,7 +768,9 @@ class PdfViewerElement extends
|
|
|
632
768
|
linkService: this.__linkService,
|
|
633
769
|
renderingQueue: pdfRenderingQueue,
|
|
634
770
|
l10n: l10n,
|
|
635
|
-
|
|
771
|
+
annotationMode: this.renderInteractiveForms
|
|
772
|
+
? pdfjsLib.AnnotationMode.ENABLE_FORMS
|
|
773
|
+
: pdfjsLib.AnnotationMode.ENABLE,
|
|
636
774
|
});
|
|
637
775
|
|
|
638
776
|
this.__linkService.setViewer(this.__viewer);
|
|
@@ -888,7 +1026,7 @@ class PdfViewerElement extends
|
|
|
888
1026
|
const pagesCount = this.__totalPages;
|
|
889
1027
|
for (let i = 0; i < pagesCount; i++) {
|
|
890
1028
|
const pageView = this.__viewer.getPageView(i);
|
|
891
|
-
if (pageView.renderingState ===
|
|
1029
|
+
if (pageView.renderingState === pdfUtils.RenderingStates.FINISHED) {
|
|
892
1030
|
const thumbnailView = this.__thumbnailViewer.getThumbnail(i);
|
|
893
1031
|
thumbnailView.setImage(pageView);
|
|
894
1032
|
} else {
|
|
@@ -914,6 +1052,24 @@ class PdfViewerElement extends
|
|
|
914
1052
|
this.__thumbnailViewer.scrollThumbnailIntoView(this.currentPage);
|
|
915
1053
|
}
|
|
916
1054
|
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Rotates document clockwise.
|
|
1058
|
+
*/
|
|
1059
|
+
rotateCw() {
|
|
1060
|
+
let delta = 90;
|
|
1061
|
+
this.__viewer.pagesRotation += delta;
|
|
1062
|
+
this.__viewer.forceRendering();
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Rotates document counterclockwise.
|
|
1067
|
+
*/
|
|
1068
|
+
rotateCcw() {
|
|
1069
|
+
let delta = -90;
|
|
1070
|
+
this.__viewer.pagesRotation += delta;
|
|
1071
|
+
this.__viewer.forceRendering();
|
|
1072
|
+
}
|
|
917
1073
|
}
|
|
918
1074
|
|
|
919
1075
|
customElements.define(PdfViewerElement.is, PdfViewerElement);
|