@vaadin-component-factory/vcf-pdf-viewer 4.0.2 → 4.1.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 +8 -2
- package/pdfjs/dist/event_utils.js +207 -0
- package/pdfjs/dist/genericl10n.js +2420 -0
- package/pdfjs/dist/message_handler.js +327 -192
- package/pdfjs/dist/node_stream.js +2 -494
- package/pdfjs/dist/node_stream2.js +1759 -0
- package/pdfjs/dist/pdf.js +17910 -9761
- package/pdfjs/dist/pdf.worker.js +24 -0
- package/pdfjs/dist/pdf_link_service.js +223 -378
- package/pdfjs/dist/pdf_rendering_queue.js +62 -62
- package/pdfjs/dist/pdf_thumbnail_viewer.js +216 -399
- package/pdfjs/dist/pdf_viewer.js +3450 -2305
- package/pdfjs/dist/ui_utils.js +209 -480
- package/pdfjs/dist/util.js +384 -595
- package/pdfjs/dist/worker.js +44555 -45401
- package/src/vcf-pdf-viewer.js +153 -16
- package/pdfjs/dist/display_utils.js +0 -848
- package/pdfjs/dist/fetch_stream.js +0 -306
- package/pdfjs/dist/l10n_utils.js +0 -140
- package/pdfjs/dist/network.js +0 -565
- package/pdfjs/dist/network_utils.js +0 -340
package/src/vcf-pdf-viewer.js
CHANGED
|
@@ -15,13 +15,13 @@ import "@vaadin/tooltip";
|
|
|
15
15
|
import * as pdfjsLib from "../pdfjs/dist/pdf";
|
|
16
16
|
import * as pdfjsViewer from "../pdfjs/dist/pdf_viewer";
|
|
17
17
|
import * as pdfUtils from "../pdfjs/dist/ui_utils";
|
|
18
|
+
import { EventBus } from "../pdfjs/dist/event_utils";
|
|
18
19
|
import * as pdfjsLinkService from "../pdfjs/dist/pdf_link_service";
|
|
19
20
|
import * as pdfjsThumbnailViewer from "../pdfjs/dist/pdf_thumbnail_viewer";
|
|
20
21
|
import * as pdfjsRenderingQueue from "../pdfjs/dist/pdf_rendering_queue";
|
|
21
|
-
import {
|
|
22
|
-
import * as pdfjsWorker from "../pdfjs/dist/worker";
|
|
22
|
+
import { GenericL10n } from "../pdfjs/dist/genericl10n";
|
|
23
23
|
|
|
24
|
-
pdfjsLib.GlobalWorkerOptions.workerSrc =
|
|
24
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = "../pdfjs/dist/worker.js";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* `<vcf-pdf-viewer>` is a Web Component for rendering PDF files without
|
|
@@ -47,6 +47,7 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
47
47
|
flex-direction: column;
|
|
48
48
|
width: 100%;
|
|
49
49
|
height: 500px;
|
|
50
|
+
--pdf-viewer-link-hover-color: rgb(255 255 0);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
:host([hidden]) {
|
|
@@ -120,7 +121,6 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
120
121
|
|
|
121
122
|
[part~="thumbnail-view"] {
|
|
122
123
|
position: absolute;
|
|
123
|
-
width: calc(100% - 60px);
|
|
124
124
|
top: 0;
|
|
125
125
|
bottom: 0;
|
|
126
126
|
padding: 10px 30px 0;
|
|
@@ -136,6 +136,14 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
136
136
|
margin: 0 auto;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
.canvasWrapper {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 0;
|
|
142
|
+
left: 0;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: 100%;
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
.textLayer {
|
|
140
148
|
position: absolute;
|
|
141
149
|
left: 0;
|
|
@@ -214,7 +222,8 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
214
222
|
}
|
|
215
223
|
|
|
216
224
|
.thumbnail {
|
|
217
|
-
margin:
|
|
225
|
+
margin: 5px;
|
|
226
|
+
padding: 7px 7px 0px 7px;
|
|
218
227
|
}
|
|
219
228
|
|
|
220
229
|
.thumbnailImage {
|
|
@@ -228,18 +237,140 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
228
237
|
background-clip: content-box;
|
|
229
238
|
}
|
|
230
239
|
|
|
231
|
-
.
|
|
232
|
-
border-radius: 2px;
|
|
233
|
-
padding: 7px;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.thumbnail.selected > .thumbnailSelectionRing {
|
|
240
|
+
.thumbnail.selected {
|
|
237
241
|
background-color: rgba(0, 0, 0, 0.15);
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
[part~="toolbar"].ready ::slotted(.toolbar-zoom.hide-zoom) {
|
|
241
245
|
display: none;
|
|
242
246
|
}
|
|
247
|
+
|
|
248
|
+
/* Annotation layer */
|
|
249
|
+
|
|
250
|
+
.annotationLayer {
|
|
251
|
+
--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>");
|
|
252
|
+
--input-focus-border-color: Highlight;
|
|
253
|
+
--input-focus-outline: 1px solid Canvas;
|
|
254
|
+
--input-unfocused-border-color: transparent;
|
|
255
|
+
--input-disabled-border-color: transparent;
|
|
256
|
+
--input-hover-border-color: black;
|
|
257
|
+
--link-outline: none;
|
|
258
|
+
position: absolute;
|
|
259
|
+
top: 0;
|
|
260
|
+
left: 0;
|
|
261
|
+
pointer-events: none;
|
|
262
|
+
transform-origin: 0 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.annotationLayer section {
|
|
266
|
+
position: absolute;
|
|
267
|
+
text-align: initial;
|
|
268
|
+
pointer-events: auto;
|
|
269
|
+
box-sizing: border-box;
|
|
270
|
+
transform-origin: 0 0;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) > a {
|
|
274
|
+
position: absolute;
|
|
275
|
+
font-size: 1em;
|
|
276
|
+
top: 0;
|
|
277
|
+
left: 0;
|
|
278
|
+
width: 100%;
|
|
279
|
+
height: 100%;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton):not(.hasBorder) > a:hover {
|
|
283
|
+
opacity: 0.2;
|
|
284
|
+
background-color: var(--pdf-viewer-link-hover-color);
|
|
285
|
+
box-shadow: 0 2px 10px var(--pdf-viewer-link-hover-color);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.annotationLayer .linkAnnotation.hasBorder:hover {
|
|
289
|
+
background-color: color-mix(in srgb, var(--pdf-viewer-link-hover-color) 20%, transparent);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.annotationLayer .hasBorder {
|
|
293
|
+
background-size: 100% 100%;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea),
|
|
297
|
+
.annotationLayer .choiceWidgetAnnotation select,
|
|
298
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
|
|
299
|
+
background-image: var(--annotation-unfocused-field-background);
|
|
300
|
+
border: 2px solid var(--input-unfocused-border-color);
|
|
301
|
+
box-sizing: border-box;
|
|
302
|
+
font: calc(9px * var(--scale-factor)) sans-serif;
|
|
303
|
+
height: 100%;
|
|
304
|
+
margin: 0;
|
|
305
|
+
vertical-align: top;
|
|
306
|
+
width: 100%;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea):hover,
|
|
310
|
+
.annotationLayer .choiceWidgetAnnotation select:hover,
|
|
311
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input:hover {
|
|
312
|
+
border: 2px solid var(--input-hover-border-color);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea):focus,
|
|
316
|
+
.annotationLayer .choiceWidgetAnnotation select:focus {
|
|
317
|
+
background: none;
|
|
318
|
+
border: 2px solid var(--input-focus-border-color);
|
|
319
|
+
border-radius: 2px;
|
|
320
|
+
outline: var(--input-focus-outline);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.annotationLayer .buttonWidgetAnnotation.radioButton input {
|
|
324
|
+
border-radius: 50%;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.annotationLayer .textWidgetAnnotation textarea {
|
|
328
|
+
resize: none;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
|
|
332
|
+
appearance: none;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before,
|
|
336
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after,
|
|
337
|
+
.annotationLayer .buttonWidgetAnnotation.radioButton input:checked::before {
|
|
338
|
+
background-color: CanvasText;
|
|
339
|
+
content: "";
|
|
340
|
+
display: block;
|
|
341
|
+
position: absolute;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before,
|
|
345
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after {
|
|
346
|
+
height: 80%;
|
|
347
|
+
left: 45%;
|
|
348
|
+
width: 1px;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::before {
|
|
352
|
+
transform: rotate(45deg);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.annotationLayer .buttonWidgetAnnotation.checkBox input:checked::after {
|
|
356
|
+
transform: rotate(-45deg);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.annotationLayer .buttonWidgetAnnotation.radioButton input:checked::before {
|
|
360
|
+
border-radius: 50%;
|
|
361
|
+
height: 50%;
|
|
362
|
+
left: 25%;
|
|
363
|
+
top: 25%;
|
|
364
|
+
width: 50%;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.annotationLayer .textWidgetAnnotation :is(input, textarea)[disabled],
|
|
368
|
+
.annotationLayer .choiceWidgetAnnotation select[disabled],
|
|
369
|
+
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input[disabled] {
|
|
370
|
+
background: none;
|
|
371
|
+
border: 2px solid var(--input-disabled-border-color);
|
|
372
|
+
cursor: not-allowed;
|
|
373
|
+
}
|
|
243
374
|
`;
|
|
244
375
|
}
|
|
245
376
|
|
|
@@ -356,7 +487,7 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
356
487
|
}
|
|
357
488
|
|
|
358
489
|
static get version() {
|
|
359
|
-
return "4.0
|
|
490
|
+
return "4.1.0";
|
|
360
491
|
}
|
|
361
492
|
|
|
362
493
|
static get properties() {
|
|
@@ -695,6 +826,10 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
695
826
|
}
|
|
696
827
|
|
|
697
828
|
firstUpdated() {
|
|
829
|
+
// Required by PDF.js annotation editor: --freetext-line-height must match
|
|
830
|
+
// the LINE_FACTOR constant (1.35) defined in src/shared/util.js
|
|
831
|
+
document.documentElement.style.setProperty('--freetext-line-height', '1.35');
|
|
832
|
+
|
|
698
833
|
this._toolbar = this.shadowRoot.querySelector("#toolbar");
|
|
699
834
|
this._viewerContainer = this.shadowRoot.querySelector("#viewerContainer");
|
|
700
835
|
this._outerContainer = this.shadowRoot.querySelector("#outerContainer");
|
|
@@ -723,7 +858,7 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
723
858
|
});
|
|
724
859
|
|
|
725
860
|
// options
|
|
726
|
-
const eventBus = new
|
|
861
|
+
const eventBus = new EventBus();
|
|
727
862
|
|
|
728
863
|
// Defer initialization of reactive controller properties to avoid immediate update request
|
|
729
864
|
// that triggers "update scheduled after update" warning.
|
|
@@ -732,7 +867,7 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
732
867
|
eventBus,
|
|
733
868
|
});
|
|
734
869
|
var pdfRenderingQueue = new pdfjsRenderingQueue.PDFRenderingQueue();
|
|
735
|
-
var l10n =
|
|
870
|
+
var l10n = new GenericL10n(navigator.language || 'en-US');
|
|
736
871
|
|
|
737
872
|
// pdfViewer
|
|
738
873
|
this.__viewer = new pdfjsViewer.PDFViewer({
|
|
@@ -743,7 +878,9 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
743
878
|
linkService: this.__linkService,
|
|
744
879
|
renderingQueue: pdfRenderingQueue,
|
|
745
880
|
l10n: l10n,
|
|
746
|
-
|
|
881
|
+
annotationMode: this.renderInteractiveForms
|
|
882
|
+
? pdfjsLib.AnnotationMode.ENABLE_FORMS
|
|
883
|
+
: pdfjsLib.AnnotationMode.ENABLE,
|
|
747
884
|
});
|
|
748
885
|
|
|
749
886
|
this.__linkService.setViewer(this.__viewer);
|
|
@@ -1002,7 +1139,7 @@ export class PdfViewerElement extends ResizeMixin(
|
|
|
1002
1139
|
for (let i = 0; i < pagesCount; i++) {
|
|
1003
1140
|
const pageView = this.__viewer.getPageView(i);
|
|
1004
1141
|
if (
|
|
1005
|
-
pageView.renderingState ===
|
|
1142
|
+
pageView.renderingState === pdfUtils.RenderingStates.FINISHED
|
|
1006
1143
|
) {
|
|
1007
1144
|
const thumbnailView = this.__thumbnailViewer.getThumbnail(i);
|
|
1008
1145
|
thumbnailView.setImage(pageView);
|