@vaadin-component-factory/vcf-pdf-viewer 3.0.2 → 4.0.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.
@@ -1,5 +1,5 @@
1
- import { u as unreachable, D as CMapCompressionType, K as BaseException, c as assert, J as removeNullCharacters, w as warn, L as isString, n as stringToBytes, e as Util } from './util.js';
2
-
1
+ import { u as unreachable, D as CMapCompressionType, q as stringToBytes, d as assert, J as removeNullCharacters, w as warn, R as isString, K as BaseException, e as Util } from './util.js';
2
+
3
3
  /* Copyright 2015 Mozilla Foundation
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,183 +13,151 @@ import { u as unreachable, D as CMapCompressionType, K as BaseException, c as as
13
13
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
- */
17
-
18
- class BaseCanvasFactory {
19
- constructor() {
20
- if (this.constructor === BaseCanvasFactory) {
21
- unreachable("Cannot initialize BaseCanvasFactory.");
22
- }
23
- }
24
-
25
- create(width, height) {
26
- if (width <= 0 || height <= 0) {
27
- throw new Error("Invalid canvas size");
28
- }
29
-
30
- const canvas = this._createCanvas(width, height);
31
-
32
- return {
33
- canvas,
34
- context: canvas.getContext("2d")
35
- };
36
- }
37
-
38
- reset(canvasAndContext, width, height) {
39
- if (!canvasAndContext.canvas) {
40
- throw new Error("Canvas is not specified");
41
- }
42
-
43
- if (width <= 0 || height <= 0) {
44
- throw new Error("Invalid canvas size");
45
- }
46
-
47
- canvasAndContext.canvas.width = width;
48
- canvasAndContext.canvas.height = height;
49
- }
50
-
51
- destroy(canvasAndContext) {
52
- if (!canvasAndContext.canvas) {
53
- throw new Error("Canvas is not specified");
54
- } // Zeroing the width and height cause Firefox to release graphics
55
- // resources immediately, which can greatly reduce memory consumption.
56
-
57
-
58
- canvasAndContext.canvas.width = 0;
59
- canvasAndContext.canvas.height = 0;
60
- canvasAndContext.canvas = null;
61
- canvasAndContext.context = null;
62
- }
16
+ */
17
+
18
+ class BaseCanvasFactory {
19
+ constructor() {
20
+ if (this.constructor === BaseCanvasFactory) {
21
+ unreachable("Cannot initialize BaseCanvasFactory.");
22
+ }
23
+ }
24
+ create(width, height) {
25
+ if (width <= 0 || height <= 0) {
26
+ throw new Error("Invalid canvas size");
27
+ }
28
+ const canvas = this._createCanvas(width, height);
29
+ return {
30
+ canvas,
31
+ context: canvas.getContext("2d")
32
+ };
33
+ }
34
+ reset(canvasAndContext, width, height) {
35
+ if (!canvasAndContext.canvas) {
36
+ throw new Error("Canvas is not specified");
37
+ }
38
+ if (width <= 0 || height <= 0) {
39
+ throw new Error("Invalid canvas size");
40
+ }
41
+ canvasAndContext.canvas.width = width;
42
+ canvasAndContext.canvas.height = height;
43
+ }
44
+ destroy(canvasAndContext) {
45
+ if (!canvasAndContext.canvas) {
46
+ throw new Error("Canvas is not specified");
47
+ }
48
+ // Zeroing the width and height cause Firefox to release graphics
49
+ // resources immediately, which can greatly reduce memory consumption.
50
+ canvasAndContext.canvas.width = 0;
51
+ canvasAndContext.canvas.height = 0;
52
+ canvasAndContext.canvas = null;
53
+ canvasAndContext.context = null;
54
+ }
55
+
63
56
  /**
64
57
  * @private
65
- */
66
-
67
-
68
- _createCanvas(width, height) {
69
- unreachable("Abstract method `_createCanvas` called.");
70
- }
71
-
72
- }
73
-
74
- class BaseCMapReaderFactory {
75
- constructor({
76
- baseUrl = null,
77
- isCompressed = false
78
- }) {
79
- if (this.constructor === BaseCMapReaderFactory) {
80
- unreachable("Cannot initialize BaseCMapReaderFactory.");
81
- }
82
-
83
- this.baseUrl = baseUrl;
84
- this.isCompressed = isCompressed;
85
- }
86
-
87
- async fetch({
88
- name
89
- }) {
90
- if (!this.baseUrl) {
91
- throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
92
- }
93
-
94
- if (!name) {
95
- throw new Error("CMap name must be specified.");
96
- }
97
-
98
- const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
99
- const compressionType = this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE;
100
- return this._fetchData(url, compressionType).catch(reason => {
101
- throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
102
- });
103
- }
58
+ */
59
+ _createCanvas(width, height) {
60
+ unreachable("Abstract method `_createCanvas` called.");
61
+ }
62
+ }
63
+ class BaseCMapReaderFactory {
64
+ constructor({
65
+ baseUrl = null,
66
+ isCompressed = false
67
+ }) {
68
+ if (this.constructor === BaseCMapReaderFactory) {
69
+ unreachable("Cannot initialize BaseCMapReaderFactory.");
70
+ }
71
+ this.baseUrl = baseUrl;
72
+ this.isCompressed = isCompressed;
73
+ }
74
+ async fetch({
75
+ name
76
+ }) {
77
+ if (!this.baseUrl) {
78
+ throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
79
+ }
80
+ if (!name) {
81
+ throw new Error("CMap name must be specified.");
82
+ }
83
+ const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
84
+ const compressionType = this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE;
85
+ return this._fetchData(url, compressionType).catch(reason => {
86
+ throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
87
+ });
88
+ }
89
+
104
90
  /**
105
91
  * @private
106
- */
107
-
108
-
109
- _fetchData(url, compressionType) {
110
- unreachable("Abstract method `_fetchData` called.");
111
- }
112
-
113
- }
114
-
115
- class BaseStandardFontDataFactory {
116
- constructor({
117
- baseUrl = null
118
- }) {
119
- if (this.constructor === BaseStandardFontDataFactory) {
120
- unreachable("Cannot initialize BaseStandardFontDataFactory.");
121
- }
122
-
123
- this.baseUrl = baseUrl;
124
- }
125
-
126
- async fetch({
127
- filename
128
- }) {
129
- if (!this.baseUrl) {
130
- throw new Error('The standard font "baseUrl" parameter must be specified, ensure that ' + 'the "standardFontDataUrl" API parameter is provided.');
131
- }
132
-
133
- if (!filename) {
134
- throw new Error("Font filename must be specified.");
135
- }
136
-
137
- const url = `${this.baseUrl}${filename}`;
138
- return this._fetchData(url).catch(reason => {
139
- throw new Error(`Unable to load font data at: ${url}`);
140
- });
141
- }
92
+ */
93
+ _fetchData(url, compressionType) {
94
+ unreachable("Abstract method `_fetchData` called.");
95
+ }
96
+ }
97
+ class BaseStandardFontDataFactory {
98
+ constructor({
99
+ baseUrl = null
100
+ }) {
101
+ if (this.constructor === BaseStandardFontDataFactory) {
102
+ unreachable("Cannot initialize BaseStandardFontDataFactory.");
103
+ }
104
+ this.baseUrl = baseUrl;
105
+ }
106
+ async fetch({
107
+ filename
108
+ }) {
109
+ if (!this.baseUrl) {
110
+ throw new Error('The standard font "baseUrl" parameter must be specified, ensure that ' + 'the "standardFontDataUrl" API parameter is provided.');
111
+ }
112
+ if (!filename) {
113
+ throw new Error("Font filename must be specified.");
114
+ }
115
+ const url = `${this.baseUrl}${filename}`;
116
+ return this._fetchData(url).catch(reason => {
117
+ throw new Error(`Unable to load font data at: ${url}`);
118
+ });
119
+ }
120
+
142
121
  /**
143
122
  * @private
144
- */
145
-
146
-
147
- _fetchData(url) {
148
- unreachable("Abstract method `_fetchData` called.");
149
- }
150
-
151
- }
152
-
153
- class BaseSVGFactory {
154
- constructor() {
155
- if (this.constructor === BaseSVGFactory) {
156
- unreachable("Cannot initialize BaseSVGFactory.");
157
- }
158
- }
159
-
160
- create(width, height) {
161
- if (width <= 0 || height <= 0) {
162
- throw new Error("Invalid SVG dimensions");
163
- }
164
-
165
- const svg = this._createSVG("svg:svg");
166
-
167
- svg.setAttribute("version", "1.1");
168
- svg.setAttribute("width", `${width}px`);
169
- svg.setAttribute("height", `${height}px`);
170
- svg.setAttribute("preserveAspectRatio", "none");
171
- svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
172
- return svg;
173
- }
174
-
175
- createElement(type) {
176
- if (typeof type !== "string") {
177
- throw new Error("Invalid SVG element type");
178
- }
179
-
180
- return this._createSVG(type);
181
- }
123
+ */
124
+ _fetchData(url) {
125
+ unreachable("Abstract method `_fetchData` called.");
126
+ }
127
+ }
128
+ class BaseSVGFactory {
129
+ constructor() {
130
+ if (this.constructor === BaseSVGFactory) {
131
+ unreachable("Cannot initialize BaseSVGFactory.");
132
+ }
133
+ }
134
+ create(width, height) {
135
+ if (width <= 0 || height <= 0) {
136
+ throw new Error("Invalid SVG dimensions");
137
+ }
138
+ const svg = this._createSVG("svg:svg");
139
+ svg.setAttribute("version", "1.1");
140
+ svg.setAttribute("width", `${width}px`);
141
+ svg.setAttribute("height", `${height}px`);
142
+ svg.setAttribute("preserveAspectRatio", "none");
143
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
144
+ return svg;
145
+ }
146
+ createElement(type) {
147
+ if (typeof type !== "string") {
148
+ throw new Error("Invalid SVG element type");
149
+ }
150
+ return this._createSVG(type);
151
+ }
152
+
182
153
  /**
183
154
  * @private
184
- */
185
-
186
-
187
- _createSVG(type) {
188
- unreachable("Abstract method `_createSVG` called.");
189
- }
190
-
191
- }
192
-
155
+ */
156
+ _createSVG(type) {
157
+ unreachable("Abstract method `_createSVG` called.");
158
+ }
159
+ }
160
+
193
161
  /* Copyright 2015 Mozilla Foundation
194
162
  *
195
163
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -203,106 +171,82 @@ class BaseSVGFactory {
203
171
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
204
172
  * See the License for the specific language governing permissions and
205
173
  * limitations under the License.
206
- */
207
- const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
208
- const SVG_NS = "http://www.w3.org/2000/svg";
209
-
210
- class DOMCanvasFactory extends BaseCanvasFactory {
211
- constructor({
212
- ownerDocument = globalThis.document
213
- } = {}) {
214
- super();
215
- this._document = ownerDocument;
216
- }
217
-
218
- _createCanvas(width, height) {
219
- const canvas = this._document.createElement("canvas");
220
-
221
- canvas.width = width;
222
- canvas.height = height;
223
- return canvas;
224
- }
225
-
226
- }
227
-
228
- async function fetchData(url, asTypedArray = false) {
229
- if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL") || isValidFetchUrl(url, document.baseURI)) {
230
- const response = await fetch(url);
231
-
232
- if (!response.ok) {
233
- throw new Error(response.statusText);
234
- }
235
-
236
- return asTypedArray ? new Uint8Array(await response.arrayBuffer()) : stringToBytes(await response.text());
237
- } // The Fetch API is not supported.
238
-
239
-
240
- return new Promise((resolve, reject) => {
241
- const request = new XMLHttpRequest();
242
- request.open("GET", url,
243
- /* asTypedArray = */
244
- true);
245
-
246
- if (asTypedArray) {
247
- request.responseType = "arraybuffer";
248
- }
249
-
250
- request.onreadystatechange = () => {
251
- if (request.readyState !== XMLHttpRequest.DONE) {
252
- return;
253
- }
254
-
255
- if (request.status === 200 || request.status === 0) {
256
- let data;
257
-
258
- if (asTypedArray && request.response) {
259
- data = new Uint8Array(request.response);
260
- } else if (!asTypedArray && request.responseText) {
261
- data = stringToBytes(request.responseText);
262
- }
263
-
264
- if (data) {
265
- resolve(data);
266
- return;
267
- }
268
- }
269
-
270
- reject(new Error(request.statusText));
271
- };
272
-
273
- request.send(null);
274
- });
275
- }
276
-
277
- class DOMCMapReaderFactory extends BaseCMapReaderFactory {
278
- _fetchData(url, compressionType) {
279
- return fetchData(url,
280
- /* asTypedArray = */
281
- this.isCompressed).then(data => {
282
- return {
283
- cMapData: data,
284
- compressionType
285
- };
286
- });
287
- }
288
-
289
- }
290
-
291
- class DOMStandardFontDataFactory extends BaseStandardFontDataFactory {
292
- _fetchData(url) {
293
- return fetchData(url,
294
- /* asTypedArray = */
295
- true);
296
- }
297
-
298
- }
299
-
300
- class DOMSVGFactory extends BaseSVGFactory {
301
- _createSVG(type) {
302
- return document.createElementNS(SVG_NS, type);
303
- }
304
-
305
- }
174
+ */
175
+
176
+ const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
177
+ const SVG_NS = "http://www.w3.org/2000/svg";
178
+ class DOMCanvasFactory extends BaseCanvasFactory {
179
+ constructor({
180
+ ownerDocument = globalThis.document
181
+ } = {}) {
182
+ super();
183
+ this._document = ownerDocument;
184
+ }
185
+ _createCanvas(width, height) {
186
+ const canvas = this._document.createElement("canvas");
187
+ canvas.width = width;
188
+ canvas.height = height;
189
+ return canvas;
190
+ }
191
+ }
192
+ async function fetchData(url, asTypedArray = false) {
193
+ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL") || isValidFetchUrl(url, document.baseURI)) {
194
+ const response = await fetch(url);
195
+ if (!response.ok) {
196
+ throw new Error(response.statusText);
197
+ }
198
+ return asTypedArray ? new Uint8Array(await response.arrayBuffer()) : stringToBytes(await response.text());
199
+ }
200
+
201
+ // The Fetch API is not supported.
202
+ return new Promise((resolve, reject) => {
203
+ const request = new XMLHttpRequest();
204
+ request.open("GET", url, /* asTypedArray = */true);
205
+ if (asTypedArray) {
206
+ request.responseType = "arraybuffer";
207
+ }
208
+ request.onreadystatechange = () => {
209
+ if (request.readyState !== XMLHttpRequest.DONE) {
210
+ return;
211
+ }
212
+ if (request.status === 200 || request.status === 0) {
213
+ let data;
214
+ if (asTypedArray && request.response) {
215
+ data = new Uint8Array(request.response);
216
+ } else if (!asTypedArray && request.responseText) {
217
+ data = stringToBytes(request.responseText);
218
+ }
219
+ if (data) {
220
+ resolve(data);
221
+ return;
222
+ }
223
+ }
224
+ reject(new Error(request.statusText));
225
+ };
226
+ request.send(null);
227
+ });
228
+ }
229
+ class DOMCMapReaderFactory extends BaseCMapReaderFactory {
230
+ _fetchData(url, compressionType) {
231
+ return fetchData(url, /* asTypedArray = */this.isCompressed).then(data => {
232
+ return {
233
+ cMapData: data,
234
+ compressionType
235
+ };
236
+ });
237
+ }
238
+ }
239
+ class DOMStandardFontDataFactory extends BaseStandardFontDataFactory {
240
+ _fetchData(url) {
241
+ return fetchData(url, /* asTypedArray = */true);
242
+ }
243
+ }
244
+ class DOMSVGFactory extends BaseSVGFactory {
245
+ _createSVG(type) {
246
+ return document.createElementNS(SVG_NS, type);
247
+ }
248
+ }
249
+
306
250
  /**
307
251
  * @typedef {Object} PageViewportParameters
308
252
  * @property {Array<number>} viewBox - The xMin, yMin, xMax and
@@ -315,8 +259,8 @@ class DOMSVGFactory extends BaseSVGFactory {
315
259
  * default value is `0`.
316
260
  * @property {boolean} [dontFlip] - If true, the y-axis will not be flipped.
317
261
  * The default value is `false`.
318
- */
319
-
262
+ */
263
+
320
264
  /**
321
265
  * @typedef {Object} PageViewportCloneParameters
322
266
  * @property {number} [scale] - The scale, overriding the one in the cloned
@@ -329,125 +273,114 @@ class DOMSVGFactory extends BaseSVGFactory {
329
273
  * The default value is `this.offsetY`.
330
274
  * @property {boolean} [dontFlip] - If true, the x-axis will not be flipped.
331
275
  * The default value is `false`.
332
- */
333
-
276
+ */
277
+
334
278
  /**
335
279
  * PDF page viewport created based on scale, rotation and offset.
336
- */
337
-
338
-
339
- class PageViewport {
280
+ */
281
+ class PageViewport {
340
282
  /**
341
283
  * @param {PageViewportParameters}
342
- */
343
- constructor({
344
- viewBox,
345
- scale,
346
- rotation,
347
- offsetX = 0,
348
- offsetY = 0,
349
- dontFlip = false
350
- }) {
351
- this.viewBox = viewBox;
352
- this.scale = scale;
353
- this.rotation = rotation;
354
- this.offsetX = offsetX;
355
- this.offsetY = offsetY; // creating transform to convert pdf coordinate system to the normal
356
- // canvas like coordinates taking in account scale and rotation
357
-
358
- const centerX = (viewBox[2] + viewBox[0]) / 2;
359
- const centerY = (viewBox[3] + viewBox[1]) / 2;
360
- let rotateA, rotateB, rotateC, rotateD; // Normalize the rotation, by clamping it to the [0, 360) range.
361
-
362
- rotation %= 360;
363
-
364
- if (rotation < 0) {
365
- rotation += 360;
366
- }
367
-
368
- switch (rotation) {
369
- case 180:
370
- rotateA = -1;
371
- rotateB = 0;
372
- rotateC = 0;
373
- rotateD = 1;
374
- break;
375
-
376
- case 90:
377
- rotateA = 0;
378
- rotateB = 1;
379
- rotateC = 1;
380
- rotateD = 0;
381
- break;
382
-
383
- case 270:
384
- rotateA = 0;
385
- rotateB = -1;
386
- rotateC = -1;
387
- rotateD = 0;
388
- break;
389
-
390
- case 0:
391
- rotateA = 1;
392
- rotateB = 0;
393
- rotateC = 0;
394
- rotateD = -1;
395
- break;
396
-
397
- default:
398
- throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
399
- }
400
-
401
- if (dontFlip) {
402
- rotateC = -rotateC;
403
- rotateD = -rotateD;
404
- }
405
-
406
- let offsetCanvasX, offsetCanvasY;
407
- let width, height;
408
-
409
- if (rotateA === 0) {
410
- offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
411
- offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
412
- width = Math.abs(viewBox[3] - viewBox[1]) * scale;
413
- height = Math.abs(viewBox[2] - viewBox[0]) * scale;
414
- } else {
415
- offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
416
- offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
417
- width = Math.abs(viewBox[2] - viewBox[0]) * scale;
418
- height = Math.abs(viewBox[3] - viewBox[1]) * scale;
419
- } // creating transform for the following operations:
420
- // translate(-centerX, -centerY), rotate and flip vertically,
421
- // scale, and translate(offsetCanvasX, offsetCanvasY)
422
-
423
-
424
- this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
425
- this.width = width;
426
- this.height = height;
427
- }
284
+ */
285
+ constructor({
286
+ viewBox,
287
+ scale,
288
+ rotation,
289
+ offsetX = 0,
290
+ offsetY = 0,
291
+ dontFlip = false
292
+ }) {
293
+ this.viewBox = viewBox;
294
+ this.scale = scale;
295
+ this.rotation = rotation;
296
+ this.offsetX = offsetX;
297
+ this.offsetY = offsetY;
298
+
299
+ // creating transform to convert pdf coordinate system to the normal
300
+ // canvas like coordinates taking in account scale and rotation
301
+ const centerX = (viewBox[2] + viewBox[0]) / 2;
302
+ const centerY = (viewBox[3] + viewBox[1]) / 2;
303
+ let rotateA, rotateB, rotateC, rotateD;
304
+ // Normalize the rotation, by clamping it to the [0, 360) range.
305
+ rotation %= 360;
306
+ if (rotation < 0) {
307
+ rotation += 360;
308
+ }
309
+ switch (rotation) {
310
+ case 180:
311
+ rotateA = -1;
312
+ rotateB = 0;
313
+ rotateC = 0;
314
+ rotateD = 1;
315
+ break;
316
+ case 90:
317
+ rotateA = 0;
318
+ rotateB = 1;
319
+ rotateC = 1;
320
+ rotateD = 0;
321
+ break;
322
+ case 270:
323
+ rotateA = 0;
324
+ rotateB = -1;
325
+ rotateC = -1;
326
+ rotateD = 0;
327
+ break;
328
+ case 0:
329
+ rotateA = 1;
330
+ rotateB = 0;
331
+ rotateC = 0;
332
+ rotateD = -1;
333
+ break;
334
+ default:
335
+ throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
336
+ }
337
+ if (dontFlip) {
338
+ rotateC = -rotateC;
339
+ rotateD = -rotateD;
340
+ }
341
+ let offsetCanvasX, offsetCanvasY;
342
+ let width, height;
343
+ if (rotateA === 0) {
344
+ offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
345
+ offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
346
+ width = Math.abs(viewBox[3] - viewBox[1]) * scale;
347
+ height = Math.abs(viewBox[2] - viewBox[0]) * scale;
348
+ } else {
349
+ offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
350
+ offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
351
+ width = Math.abs(viewBox[2] - viewBox[0]) * scale;
352
+ height = Math.abs(viewBox[3] - viewBox[1]) * scale;
353
+ }
354
+ // creating transform for the following operations:
355
+ // translate(-centerX, -centerY), rotate and flip vertically,
356
+ // scale, and translate(offsetCanvasX, offsetCanvasY)
357
+ this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
358
+ this.width = width;
359
+ this.height = height;
360
+ }
361
+
428
362
  /**
429
363
  * Clones viewport, with optional additional properties.
430
364
  * @param {PageViewportCloneParameters} [params]
431
365
  * @returns {PageViewport} Cloned viewport.
432
- */
433
-
434
-
435
- clone({
436
- scale = this.scale,
437
- rotation = this.rotation,
438
- offsetX = this.offsetX,
439
- offsetY = this.offsetY,
440
- dontFlip = false
441
- } = {}) {
442
- return new PageViewport({
443
- viewBox: this.viewBox.slice(),
444
- scale,
445
- rotation,
446
- offsetX,
447
- offsetY,
448
- dontFlip
449
- });
450
- }
366
+ */
367
+ clone({
368
+ scale = this.scale,
369
+ rotation = this.rotation,
370
+ offsetX = this.offsetX,
371
+ offsetY = this.offsetY,
372
+ dontFlip = false
373
+ } = {}) {
374
+ return new PageViewport({
375
+ viewBox: this.viewBox.slice(),
376
+ scale,
377
+ rotation,
378
+ offsetX,
379
+ offsetY,
380
+ dontFlip
381
+ });
382
+ }
383
+
451
384
  /**
452
385
  * Converts PDF point to the viewport coordinates. For examples, useful for
453
386
  * converting PDF location into canvas pixel coordinates.
@@ -457,26 +390,24 @@ class PageViewport {
457
390
  * point in the viewport coordinate space.
458
391
  * @see {@link convertToPdfPoint}
459
392
  * @see {@link convertToViewportRectangle}
460
- */
461
-
462
-
463
- convertToViewportPoint(x, y) {
464
- return Util.applyTransform([x, y], this.transform);
465
- }
393
+ */
394
+ convertToViewportPoint(x, y) {
395
+ return Util.applyTransform([x, y], this.transform);
396
+ }
397
+
466
398
  /**
467
399
  * Converts PDF rectangle to the viewport coordinates.
468
400
  * @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.
469
401
  * @returns {Array} Array containing corresponding coordinates of the
470
402
  * rectangle in the viewport coordinate space.
471
403
  * @see {@link convertToViewportPoint}
472
- */
473
-
474
-
475
- convertToViewportRectangle(rect) {
476
- const topLeft = Util.applyTransform([rect[0], rect[1]], this.transform);
477
- const bottomRight = Util.applyTransform([rect[2], rect[3]], this.transform);
478
- return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
479
- }
404
+ */
405
+ convertToViewportRectangle(rect) {
406
+ const topLeft = Util.applyTransform([rect[0], rect[1]], this.transform);
407
+ const bottomRight = Util.applyTransform([rect[2], rect[3]], this.transform);
408
+ return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
409
+ }
410
+
480
411
  /**
481
412
  * Converts viewport coordinates to the PDF location. For examples, useful
482
413
  * for converting canvas pixel location into PDF one.
@@ -485,31 +416,26 @@ class PageViewport {
485
416
  * @returns {Object} Object containing `x` and `y` properties of the
486
417
  * point in the PDF coordinate space.
487
418
  * @see {@link convertToViewportPoint}
488
- */
489
-
490
-
491
- convertToPdfPoint(x, y) {
492
- return Util.applyInverseTransform([x, y], this.transform);
493
- }
494
-
495
- }
496
-
497
- class RenderingCancelledException extends BaseException {
498
- constructor(msg, type) {
499
- super(msg);
500
- this.type = type;
501
- }
502
-
503
- }
504
-
505
- const LinkTarget = {
506
- NONE: 0,
507
- // Default value.
508
- SELF: 1,
509
- BLANK: 2,
510
- PARENT: 3,
511
- TOP: 4
512
- };
419
+ */
420
+ convertToPdfPoint(x, y) {
421
+ return Util.applyInverseTransform([x, y], this.transform);
422
+ }
423
+ }
424
+ class RenderingCancelledException extends BaseException {
425
+ constructor(msg, type) {
426
+ super(msg);
427
+ this.type = type;
428
+ }
429
+ }
430
+ const LinkTarget = {
431
+ NONE: 0,
432
+ // Default value.
433
+ SELF: 1,
434
+ BLANK: 2,
435
+ PARENT: 3,
436
+ TOP: 4
437
+ };
438
+
513
439
  /**
514
440
  * @typedef ExternalLinkParameters
515
441
  * @typedef {Object} ExternalLinkParameters
@@ -520,229 +446,190 @@ const LinkTarget = {
520
446
  * `DEFAULT_LINK_REL`.
521
447
  * @property {boolean} [enabled] - Whether the link should be enabled. The
522
448
  * default value is true.
523
- */
524
-
449
+ */
450
+
525
451
  /**
526
452
  * Adds various attributes (href, title, target, rel) to hyperlinks.
527
453
  * @param {HTMLLinkElement} link - The link element.
528
454
  * @param {ExternalLinkParameters} params
529
- */
530
-
531
- function addLinkAttributes(link, {
532
- url,
533
- target,
534
- rel,
535
- enabled = true
536
- } = {}) {
537
- assert(url && typeof url === "string", 'addLinkAttributes: A valid "url" parameter must provided.');
538
- const urlNullRemoved = removeNullCharacters(url);
539
-
540
- if (enabled) {
541
- link.href = link.title = urlNullRemoved;
542
- } else {
543
- link.href = "";
544
- link.title = `Disabled: ${urlNullRemoved}`;
545
-
546
- link.onclick = () => {
547
- return false;
548
- };
549
- }
550
-
551
- let targetStr = ""; // LinkTarget.NONE
552
-
553
- switch (target) {
554
- case LinkTarget.NONE:
555
- break;
556
-
557
- case LinkTarget.SELF:
558
- targetStr = "_self";
559
- break;
560
-
561
- case LinkTarget.BLANK:
562
- targetStr = "_blank";
563
- break;
564
-
565
- case LinkTarget.PARENT:
566
- targetStr = "_parent";
567
- break;
568
-
569
- case LinkTarget.TOP:
570
- targetStr = "_top";
571
- break;
572
- }
573
-
574
- link.target = targetStr;
575
- link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
576
- }
577
-
578
- function isDataScheme(url) {
579
- const ii = url.length;
580
- let i = 0;
581
-
582
- while (i < ii && url[i].trim() === "") {
583
- i++;
584
- }
585
-
586
- return url.substring(i, i + 5).toLowerCase() === "data:";
587
- }
588
-
589
- function isPdfFile(filename) {
590
- return typeof filename === "string" && /\.pdf$/i.test(filename);
591
- }
455
+ */
456
+ function addLinkAttributes(link, {
457
+ url,
458
+ target,
459
+ rel,
460
+ enabled = true
461
+ } = {}) {
462
+ assert(url && typeof url === "string", 'addLinkAttributes: A valid "url" parameter must provided.');
463
+ const urlNullRemoved = removeNullCharacters(url);
464
+ if (enabled) {
465
+ link.href = link.title = urlNullRemoved;
466
+ } else {
467
+ link.href = "";
468
+ link.title = `Disabled: ${urlNullRemoved}`;
469
+ link.onclick = () => {
470
+ return false;
471
+ };
472
+ }
473
+ let targetStr = ""; // LinkTarget.NONE
474
+ switch (target) {
475
+ case LinkTarget.NONE:
476
+ break;
477
+ case LinkTarget.SELF:
478
+ targetStr = "_self";
479
+ break;
480
+ case LinkTarget.BLANK:
481
+ targetStr = "_blank";
482
+ break;
483
+ case LinkTarget.PARENT:
484
+ targetStr = "_parent";
485
+ break;
486
+ case LinkTarget.TOP:
487
+ targetStr = "_top";
488
+ break;
489
+ }
490
+ link.target = targetStr;
491
+ link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
492
+ }
493
+ function isDataScheme(url) {
494
+ const ii = url.length;
495
+ let i = 0;
496
+ while (i < ii && url[i].trim() === "") {
497
+ i++;
498
+ }
499
+ return url.substring(i, i + 5).toLowerCase() === "data:";
500
+ }
501
+ function isPdfFile(filename) {
502
+ return typeof filename === "string" && /\.pdf$/i.test(filename);
503
+ }
504
+
592
505
  /**
593
506
  * Gets the filename from a given URL.
594
507
  * @param {string} url
595
508
  * @returns {string}
596
- */
597
-
598
-
599
- function getFilenameFromUrl(url) {
600
- const anchor = url.indexOf("#");
601
- const query = url.indexOf("?");
602
- const end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
603
- return url.substring(url.lastIndexOf("/", end) + 1, end);
604
- }
509
+ */
510
+ function getFilenameFromUrl(url) {
511
+ const anchor = url.indexOf("#");
512
+ const query = url.indexOf("?");
513
+ const end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
514
+ return url.substring(url.lastIndexOf("/", end) + 1, end);
515
+ }
516
+
605
517
  /**
606
518
  * Returns the filename or guessed filename from the url (see issue 3455).
607
519
  * @param {string} url - The original PDF location.
608
520
  * @param {string} defaultFilename - The value returned if the filename is
609
521
  * unknown, or the protocol is unsupported.
610
522
  * @returns {string} Guessed PDF filename.
611
- */
612
-
613
-
614
- function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
615
- if (typeof url !== "string") {
616
- return defaultFilename;
617
- }
618
-
619
- if (isDataScheme(url)) {
620
- warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
621
- return defaultFilename;
622
- }
623
-
624
- const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; // SCHEME HOST 1.PATH 2.QUERY 3.REF
625
- // Pattern to get last matching NAME.pdf
626
-
627
- const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
628
- const splitURI = reURI.exec(url);
629
- let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
630
-
631
- if (suggestedFilename) {
632
- suggestedFilename = suggestedFilename[0];
633
-
634
- if (suggestedFilename.includes("%")) {
635
- // URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
636
- try {
637
- suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
638
- } catch (ex) {// Possible (extremely rare) errors:
639
- // URIError "Malformed URI", e.g. for "%AA.pdf"
640
- // TypeError "null has no properties", e.g. for "%2F.pdf"
641
- }
642
- }
643
- }
644
-
645
- return suggestedFilename || defaultFilename;
646
- }
647
-
648
- class StatTimer {
649
- constructor() {
650
- this.started = Object.create(null);
651
- this.times = [];
652
- }
653
-
654
- time(name) {
655
- if (name in this.started) {
656
- warn(`Timer is already running for ${name}`);
657
- }
658
-
659
- this.started[name] = Date.now();
660
- }
661
-
662
- timeEnd(name) {
663
- if (!(name in this.started)) {
664
- warn(`Timer has not been started for ${name}`);
665
- }
666
-
667
- this.times.push({
668
- name,
669
- start: this.started[name],
670
- end: Date.now()
671
- }); // Remove timer from started so it can be called again.
672
-
673
- delete this.started[name];
674
- }
675
-
676
- toString() {
677
- // Find the longest name for padding purposes.
678
- const outBuf = [];
679
- let longest = 0;
680
-
681
- for (const time of this.times) {
682
- const name = time.name;
683
-
684
- if (name.length > longest) {
685
- longest = name.length;
686
- }
687
- }
688
-
689
- for (const time of this.times) {
690
- const duration = time.end - time.start;
691
- outBuf.push(`${time.name.padEnd(longest)} ${duration}ms\n`);
692
- }
693
-
694
- return outBuf.join("");
695
- }
696
-
697
- }
698
-
699
- function isValidFetchUrl(url, baseUrl) {
700
- try {
701
- const {
702
- protocol
703
- } = baseUrl ? new URL(url, baseUrl) : new URL(url); // The Fetch API only supports the http/https protocols, and not file/ftp.
704
-
705
- return protocol === "http:" || protocol === "https:";
706
- } catch (ex) {
707
- return false; // `new URL()` will throw on incorrect data.
708
- }
709
- }
523
+ */
524
+ function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
525
+ if (typeof url !== "string") {
526
+ return defaultFilename;
527
+ }
528
+ if (isDataScheme(url)) {
529
+ warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
530
+ return defaultFilename;
531
+ }
532
+ const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
533
+ // SCHEME HOST 1.PATH 2.QUERY 3.REF
534
+ // Pattern to get last matching NAME.pdf
535
+ const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
536
+ const splitURI = reURI.exec(url);
537
+ let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
538
+ if (suggestedFilename) {
539
+ suggestedFilename = suggestedFilename[0];
540
+ if (suggestedFilename.includes("%")) {
541
+ // URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
542
+ try {
543
+ suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
544
+ } catch (ex) {
545
+ // Possible (extremely rare) errors:
546
+ // URIError "Malformed URI", e.g. for "%AA.pdf"
547
+ // TypeError "null has no properties", e.g. for "%2F.pdf"
548
+ }
549
+ }
550
+ }
551
+ return suggestedFilename || defaultFilename;
552
+ }
553
+ class StatTimer {
554
+ constructor() {
555
+ this.started = Object.create(null);
556
+ this.times = [];
557
+ }
558
+ time(name) {
559
+ if (name in this.started) {
560
+ warn(`Timer is already running for ${name}`);
561
+ }
562
+ this.started[name] = Date.now();
563
+ }
564
+ timeEnd(name) {
565
+ if (!(name in this.started)) {
566
+ warn(`Timer has not been started for ${name}`);
567
+ }
568
+ this.times.push({
569
+ name,
570
+ start: this.started[name],
571
+ end: Date.now()
572
+ });
573
+ // Remove timer from started so it can be called again.
574
+ delete this.started[name];
575
+ }
576
+ toString() {
577
+ // Find the longest name for padding purposes.
578
+ const outBuf = [];
579
+ let longest = 0;
580
+ for (const time of this.times) {
581
+ const name = time.name;
582
+ if (name.length > longest) {
583
+ longest = name.length;
584
+ }
585
+ }
586
+ for (const time of this.times) {
587
+ const duration = time.end - time.start;
588
+ outBuf.push(`${time.name.padEnd(longest)} ${duration}ms\n`);
589
+ }
590
+ return outBuf.join("");
591
+ }
592
+ }
593
+ function isValidFetchUrl(url, baseUrl) {
594
+ try {
595
+ const {
596
+ protocol
597
+ } = baseUrl ? new URL(url, baseUrl) : new URL(url);
598
+ // The Fetch API only supports the http/https protocols, and not file/ftp.
599
+ return protocol === "http:" || protocol === "https:";
600
+ } catch (ex) {
601
+ return false; // `new URL()` will throw on incorrect data.
602
+ }
603
+ }
604
+
710
605
  /**
711
606
  * @param {string} src
712
607
  * @param {boolean} [removeScriptElement]
713
608
  * @returns {Promise<void>}
714
- */
715
-
716
-
717
- function loadScript(src, removeScriptElement = false) {
718
- return new Promise((resolve, reject) => {
719
- const script = document.createElement("script");
720
- script.src = src;
721
-
722
- script.onload = function (evt) {
723
- if (removeScriptElement) {
724
- script.remove();
725
- }
726
-
727
- resolve(evt);
728
- };
729
-
730
- script.onerror = function () {
731
- reject(new Error(`Cannot load script at: ${script.src}`));
732
- };
733
-
734
- (document.head || document.documentElement).appendChild(script);
735
- });
736
- } // Deprecated API function -- display regardless of the `verbosity` setting.
737
-
738
-
739
- function deprecated(details) {
740
- console.log("Deprecated API usage: " + details);
741
- }
742
-
743
- let pdfDateStringRegex;
744
-
745
- class PDFDateString {
609
+ */
610
+ function loadScript(src, removeScriptElement = false) {
611
+ return new Promise((resolve, reject) => {
612
+ const script = document.createElement("script");
613
+ script.src = src;
614
+ script.onload = function (evt) {
615
+ if (removeScriptElement) {
616
+ script.remove();
617
+ }
618
+ resolve(evt);
619
+ };
620
+ script.onerror = function () {
621
+ reject(new Error(`Cannot load script at: ${script.src}`));
622
+ };
623
+ (document.head || document.documentElement).appendChild(script);
624
+ });
625
+ }
626
+
627
+ // Deprecated API function -- display regardless of the `verbosity` setting.
628
+ function deprecated(details) {
629
+ console.log("Deprecated API usage: " + details);
630
+ }
631
+ let pdfDateStringRegex;
632
+ class PDFDateString {
746
633
  /**
747
634
  * Convert a PDF date string to a JavaScript `Date` object.
748
635
  *
@@ -758,91 +645,99 @@ class PDFDateString {
758
645
  *
759
646
  * @param {string} input
760
647
  * @returns {Date|null}
761
- */
762
- static toDateObject(input) {
763
- if (!input || !isString(input)) {
764
- return null;
765
- } // Lazily initialize the regular expression.
766
-
767
-
768
- if (!pdfDateStringRegex) {
769
- pdfDateStringRegex = new RegExp("^D:" + // Prefix (required)
770
- "(\\d{4})" + // Year (required)
771
- "(\\d{2})?" + // Month (optional)
772
- "(\\d{2})?" + // Day (optional)
773
- "(\\d{2})?" + // Hour (optional)
774
- "(\\d{2})?" + // Minute (optional)
775
- "(\\d{2})?" + // Second (optional)
776
- "([Z|+|-])?" + // Universal time relation (optional)
777
- "(\\d{2})?" + // Offset hour (optional)
778
- "'?" + // Splitting apostrophe (optional)
779
- "(\\d{2})?" + // Offset minute (optional)
780
- "'?" // Trailing apostrophe (optional)
781
- );
782
- } // Optional fields that don't satisfy the requirements from the regular
783
- // expression (such as incorrect digit counts or numbers that are out of
784
- // range) will fall back the defaults from the specification.
785
-
786
-
787
- const matches = pdfDateStringRegex.exec(input);
788
-
789
- if (!matches) {
790
- return null;
791
- } // JavaScript's `Date` object expects the month to be between 0 and 11
792
- // instead of 1 and 12, so we have to correct for that.
793
-
794
-
795
- const year = parseInt(matches[1], 10);
796
- let month = parseInt(matches[2], 10);
797
- month = month >= 1 && month <= 12 ? month - 1 : 0;
798
- let day = parseInt(matches[3], 10);
799
- day = day >= 1 && day <= 31 ? day : 1;
800
- let hour = parseInt(matches[4], 10);
801
- hour = hour >= 0 && hour <= 23 ? hour : 0;
802
- let minute = parseInt(matches[5], 10);
803
- minute = minute >= 0 && minute <= 59 ? minute : 0;
804
- let second = parseInt(matches[6], 10);
805
- second = second >= 0 && second <= 59 ? second : 0;
806
- const universalTimeRelation = matches[7] || "Z";
807
- let offsetHour = parseInt(matches[8], 10);
808
- offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
809
- let offsetMinute = parseInt(matches[9], 10) || 0;
810
- offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0; // Universal time relation 'Z' means that the local time is equal to the
811
- // universal time, whereas the relations '+'/'-' indicate that the local
812
- // time is later respectively earlier than the universal time. Every date
813
- // is normalized to universal time.
814
-
815
- if (universalTimeRelation === "-") {
816
- hour += offsetHour;
817
- minute += offsetMinute;
818
- } else if (universalTimeRelation === "+") {
819
- hour -= offsetHour;
820
- minute -= offsetMinute;
821
- }
822
-
823
- return new Date(Date.UTC(year, month, day, hour, minute, second));
824
- }
825
-
826
- }
648
+ */
649
+ static toDateObject(input) {
650
+ if (!input || !isString(input)) {
651
+ return null;
652
+ }
653
+
654
+ // Lazily initialize the regular expression.
655
+ if (!pdfDateStringRegex) {
656
+ pdfDateStringRegex = new RegExp("^D:" +
657
+ // Prefix (required)
658
+ "(\\d{4})" +
659
+ // Year (required)
660
+ "(\\d{2})?" +
661
+ // Month (optional)
662
+ "(\\d{2})?" +
663
+ // Day (optional)
664
+ "(\\d{2})?" +
665
+ // Hour (optional)
666
+ "(\\d{2})?" +
667
+ // Minute (optional)
668
+ "(\\d{2})?" +
669
+ // Second (optional)
670
+ "([Z|+|-])?" +
671
+ // Universal time relation (optional)
672
+ "(\\d{2})?" +
673
+ // Offset hour (optional)
674
+ "'?" +
675
+ // Splitting apostrophe (optional)
676
+ "(\\d{2})?" +
677
+ // Offset minute (optional)
678
+ "'?" // Trailing apostrophe (optional)
679
+ );
680
+ }
681
+
682
+ // Optional fields that don't satisfy the requirements from the regular
683
+ // expression (such as incorrect digit counts or numbers that are out of
684
+ // range) will fall back the defaults from the specification.
685
+ const matches = pdfDateStringRegex.exec(input);
686
+ if (!matches) {
687
+ return null;
688
+ }
689
+
690
+ // JavaScript's `Date` object expects the month to be between 0 and 11
691
+ // instead of 1 and 12, so we have to correct for that.
692
+ const year = parseInt(matches[1], 10);
693
+ let month = parseInt(matches[2], 10);
694
+ month = month >= 1 && month <= 12 ? month - 1 : 0;
695
+ let day = parseInt(matches[3], 10);
696
+ day = day >= 1 && day <= 31 ? day : 1;
697
+ let hour = parseInt(matches[4], 10);
698
+ hour = hour >= 0 && hour <= 23 ? hour : 0;
699
+ let minute = parseInt(matches[5], 10);
700
+ minute = minute >= 0 && minute <= 59 ? minute : 0;
701
+ let second = parseInt(matches[6], 10);
702
+ second = second >= 0 && second <= 59 ? second : 0;
703
+ const universalTimeRelation = matches[7] || "Z";
704
+ let offsetHour = parseInt(matches[8], 10);
705
+ offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
706
+ let offsetMinute = parseInt(matches[9], 10) || 0;
707
+ offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
708
+
709
+ // Universal time relation 'Z' means that the local time is equal to the
710
+ // universal time, whereas the relations '+'/'-' indicate that the local
711
+ // time is later respectively earlier than the universal time. Every date
712
+ // is normalized to universal time.
713
+ if (universalTimeRelation === "-") {
714
+ hour += offsetHour;
715
+ minute += offsetMinute;
716
+ } else if (universalTimeRelation === "+") {
717
+ hour -= offsetHour;
718
+ minute -= offsetMinute;
719
+ }
720
+ return new Date(Date.UTC(year, month, day, hour, minute, second));
721
+ }
722
+ }
723
+
827
724
  /**
828
725
  * NOTE: This is (mostly) intended to support printing of XFA forms.
829
- */
830
-
831
-
832
- function getXfaPageViewport(xfaPage, {
833
- scale = 1,
834
- rotation = 0
835
- }) {
836
- const {
837
- width,
838
- height
839
- } = xfaPage.attributes.style;
840
- const viewBox = [0, 0, parseInt(width), parseInt(height)];
841
- return new PageViewport({
842
- viewBox,
843
- scale,
844
- rotation
845
- });
846
- }
847
-
848
- export { BaseCanvasFactory as B, DOMCanvasFactory as D, LinkTarget as L, PageViewport as P, RenderingCancelledException as R, StatTimer as S, BaseCMapReaderFactory as a, BaseStandardFontDataFactory as b, DOMCMapReaderFactory as c, DOMStandardFontDataFactory as d, isDataScheme as e, deprecated as f, DOMSVGFactory as g, addLinkAttributes as h, isPdfFile as i, PDFDateString as j, getFilenameFromUrl as k, loadScript as l, isValidFetchUrl as m, getPdfFilenameFromUrl as n, getXfaPageViewport as o };
726
+ */
727
+ function getXfaPageViewport(xfaPage, {
728
+ scale = 1,
729
+ rotation = 0
730
+ }) {
731
+ const {
732
+ width,
733
+ height
734
+ } = xfaPage.attributes.style;
735
+ const viewBox = [0, 0, parseInt(width), parseInt(height)];
736
+ return new PageViewport({
737
+ viewBox,
738
+ scale,
739
+ rotation
740
+ });
741
+ }
742
+
743
+ export { BaseCanvasFactory as B, DOMCanvasFactory as D, LinkTarget as L, PageViewport as P, RenderingCancelledException as R, StatTimer as S, BaseCMapReaderFactory as a, BaseStandardFontDataFactory as b, DOMCMapReaderFactory as c, DOMStandardFontDataFactory as d, deprecated as e, isDataScheme as f, DOMSVGFactory as g, getFilenameFromUrl as h, isPdfFile as i, addLinkAttributes as j, PDFDateString as k, loadScript as l, isValidFetchUrl as m, getPdfFilenameFromUrl as n, getXfaPageViewport as o };