pdfmake 0.3.0-beta.12 → 0.3.0-beta.13

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/build/pdfmake.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! pdfmake v0.3.0-beta.12, @license MIT, @link http://pdfmake.org */
1
+ /*! pdfmake v0.3.0-beta.13, @license MIT, @link http://pdfmake.org */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory();
@@ -23,7 +23,7 @@ __webpack_require__.d(__webpack_exports__, {
23
23
  });
24
24
 
25
25
  // EXTERNAL MODULE: ./node_modules/@foliojs-fork/pdfkit/js/pdfkit.es.js
26
- var pdfkit_es = __webpack_require__(4098);
26
+ var pdfkit_es = __webpack_require__(9308);
27
27
  ;// ./src/PDFDocument.js
28
28
  /* provided dependency */ var Buffer = __webpack_require__(4598)["Buffer"];
29
29
 
@@ -919,7 +919,7 @@ class TextInlines {
919
919
  * Converts an array of strings (or inline-definition-objects) into a collection
920
920
  * of inlines and calculated minWidth/maxWidth and their min/max widths
921
921
  *
922
- * @param {Array} textArray an array of inline-definition-objects (or strings)
922
+ * @param {Array|object} textArray an array of inline-definition-objects (or strings)
923
923
  * @param {StyleContextStack} styleContextStack current style stack
924
924
  * @returns {object} collection of inlines, minWidth, maxWidth
925
925
  */
@@ -1358,6 +1358,11 @@ function offsetVector(vector, x, y) {
1358
1358
  break;
1359
1359
  }
1360
1360
  }
1361
+ function convertToDynamicContent(staticContent) {
1362
+ return () =>
1363
+ // copy to new object
1364
+ JSON.parse(JSON.stringify(staticContent));
1365
+ }
1361
1366
  ;// ./src/qrEnc.js
1362
1367
  /*eslint no-unused-vars: ["error", {"args": "none"}]*/
1363
1368
  /*eslint no-redeclare: "off"*/
@@ -2193,6 +2198,15 @@ class DocMeasure {
2193
2198
  width: image.width,
2194
2199
  height: image.height
2195
2200
  };
2201
+ if (image.constructor.name === 'JPEG') {
2202
+ // If EXIF orientation calls for it, swap width and height
2203
+ if (image.orientation > 4) {
2204
+ imageSize = {
2205
+ width: image.height,
2206
+ height: image.width
2207
+ };
2208
+ }
2209
+ }
2196
2210
  this.measureImageWithDimensions(node, imageSize);
2197
2211
  return node;
2198
2212
  }
@@ -2711,17 +2725,16 @@ var events = __webpack_require__(4785);
2711
2725
  * It facilitates column divisions and vertical sync
2712
2726
  */
2713
2727
  class DocumentContext extends events.EventEmitter {
2714
- constructor(pageSize, pageMargins) {
2728
+ constructor() {
2715
2729
  super();
2716
2730
  this.pages = [];
2717
- this.pageMargins = pageMargins;
2718
- this.x = pageMargins.left;
2719
- this.availableWidth = pageSize.width - pageMargins.left - pageMargins.right;
2720
- this.availableHeight = 0;
2731
+ this.pageMargins = undefined;
2732
+ this.x = undefined;
2733
+ this.availableWidth = undefined;
2734
+ this.availableHeight = undefined;
2721
2735
  this.page = -1;
2722
2736
  this.snapshots = [];
2723
2737
  this.backgroundLength = [];
2724
- this.addPage(pageSize);
2725
2738
  }
2726
2739
  beginColumnGroup(marginXTopParent, bottomByPage) {
2727
2740
  if (bottomByPage === void 0) {
@@ -2925,10 +2938,19 @@ class DocumentContext extends events.EventEmitter {
2925
2938
  y: this.y
2926
2939
  };
2927
2940
  }
2928
- addPage(pageSize) {
2941
+ addPage(pageSize, pageMargin) {
2942
+ if (pageMargin === void 0) {
2943
+ pageMargin = null;
2944
+ }
2945
+ if (pageMargin !== null) {
2946
+ this.pageMargins = pageMargin;
2947
+ this.x = pageMargin.left;
2948
+ this.availableWidth = pageSize.width - pageMargin.left - pageMargin.right;
2949
+ }
2929
2950
  let page = {
2930
2951
  items: [],
2931
- pageSize: pageSize
2952
+ pageSize: pageSize,
2953
+ pageMargins: this.pageMargins
2932
2954
  };
2933
2955
  this.pages.push(page);
2934
2956
  this.backgroundLength.push(0);
@@ -3013,11 +3035,18 @@ function bottomMostContext(c1, c2) {
3013
3035
  * their positions based on the context
3014
3036
  */
3015
3037
  class ElementWriter extends events.EventEmitter {
3038
+ /**
3039
+ * @param {DocumentContext} context
3040
+ */
3016
3041
  constructor(context) {
3017
3042
  super();
3018
3043
  this._context = context;
3019
3044
  this.contextStack = [];
3020
3045
  }
3046
+
3047
+ /**
3048
+ * @returns {DocumentContext}
3049
+ */
3021
3050
  context() {
3022
3051
  return this._context;
3023
3052
  }
@@ -3307,7 +3336,7 @@ class ElementWriter extends events.EventEmitter {
3307
3336
  * pushContext(width, height) - creates and pushes a new context with the specified width and height
3308
3337
  * pushContext() - creates a new context for unbreakable blocks (with current availableWidth and full-page-height)
3309
3338
  *
3310
- * @param {object|number} contextOrWidth
3339
+ * @param {DocumentContext|number} contextOrWidth
3311
3340
  * @param {number} height
3312
3341
  */
3313
3342
  pushContext(contextOrWidth, height) {
@@ -3316,8 +3345,10 @@ class ElementWriter extends events.EventEmitter {
3316
3345
  contextOrWidth = this.context().availableWidth;
3317
3346
  }
3318
3347
  if (isNumber(contextOrWidth)) {
3319
- contextOrWidth = new src_DocumentContext({
3320
- width: contextOrWidth,
3348
+ let width = contextOrWidth;
3349
+ contextOrWidth = new src_DocumentContext();
3350
+ contextOrWidth.addPage({
3351
+ width: width,
3321
3352
  height: height
3322
3353
  }, {
3323
3354
  left: 0,
@@ -3344,9 +3375,133 @@ function addPageItem(page, item, index) {
3344
3375
  }
3345
3376
  }
3346
3377
  /* harmony default export */ var src_ElementWriter = (ElementWriter);
3378
+ ;// ./src/standardPageSizes.js
3379
+ /* harmony default export */ var standardPageSizes = ({
3380
+ '4A0': [4767.87, 6740.79],
3381
+ '2A0': [3370.39, 4767.87],
3382
+ A0: [2383.94, 3370.39],
3383
+ A1: [1683.78, 2383.94],
3384
+ A2: [1190.55, 1683.78],
3385
+ A3: [841.89, 1190.55],
3386
+ A4: [595.28, 841.89],
3387
+ A5: [419.53, 595.28],
3388
+ A6: [297.64, 419.53],
3389
+ A7: [209.76, 297.64],
3390
+ A8: [147.40, 209.76],
3391
+ A9: [104.88, 147.40],
3392
+ A10: [73.70, 104.88],
3393
+ B0: [2834.65, 4008.19],
3394
+ B1: [2004.09, 2834.65],
3395
+ B2: [1417.32, 2004.09],
3396
+ B3: [1000.63, 1417.32],
3397
+ B4: [708.66, 1000.63],
3398
+ B5: [498.90, 708.66],
3399
+ B6: [354.33, 498.90],
3400
+ B7: [249.45, 354.33],
3401
+ B8: [175.75, 249.45],
3402
+ B9: [124.72, 175.75],
3403
+ B10: [87.87, 124.72],
3404
+ C0: [2599.37, 3676.54],
3405
+ C1: [1836.85, 2599.37],
3406
+ C2: [1298.27, 1836.85],
3407
+ C3: [918.43, 1298.27],
3408
+ C4: [649.13, 918.43],
3409
+ C5: [459.21, 649.13],
3410
+ C6: [323.15, 459.21],
3411
+ C7: [229.61, 323.15],
3412
+ C8: [161.57, 229.61],
3413
+ C9: [113.39, 161.57],
3414
+ C10: [79.37, 113.39],
3415
+ RA0: [2437.80, 3458.27],
3416
+ RA1: [1729.13, 2437.80],
3417
+ RA2: [1218.90, 1729.13],
3418
+ RA3: [864.57, 1218.90],
3419
+ RA4: [609.45, 864.57],
3420
+ SRA0: [2551.18, 3628.35],
3421
+ SRA1: [1814.17, 2551.18],
3422
+ SRA2: [1275.59, 1814.17],
3423
+ SRA3: [907.09, 1275.59],
3424
+ SRA4: [637.80, 907.09],
3425
+ EXECUTIVE: [521.86, 756.00],
3426
+ FOLIO: [612.00, 936.00],
3427
+ LEGAL: [612.00, 1008.00],
3428
+ LETTER: [612.00, 792.00],
3429
+ TABLOID: [792.00, 1224.00]
3430
+ });
3431
+ ;// ./src/PageSize.js
3432
+
3433
+
3434
+ function normalizePageSize(pageSize, pageOrientation) {
3435
+ function isNeedSwapPageSizes(pageOrientation) {
3436
+ if (isString(pageOrientation)) {
3437
+ pageOrientation = pageOrientation.toLowerCase();
3438
+ return pageOrientation === 'portrait' && size.width > size.height || pageOrientation === 'landscape' && size.width < size.height;
3439
+ }
3440
+ return false;
3441
+ }
3442
+ function pageSizeToWidthAndHeight(pageSize) {
3443
+ if (isString(pageSize)) {
3444
+ let size = standardPageSizes[pageSize.toUpperCase()];
3445
+ if (!size) {
3446
+ throw new Error(`Page size ${pageSize} not recognized`);
3447
+ }
3448
+ return {
3449
+ width: size[0],
3450
+ height: size[1]
3451
+ };
3452
+ }
3453
+ return pageSize;
3454
+ }
3455
+
3456
+ // if pageSize.height is set to auto, set the height to infinity so there are no page breaks.
3457
+ if (pageSize && pageSize.height === 'auto') {
3458
+ pageSize.height = Infinity;
3459
+ }
3460
+ let size = pageSizeToWidthAndHeight(pageSize || 'A4');
3461
+ if (isNeedSwapPageSizes(pageOrientation)) {
3462
+ // swap page sizes
3463
+ size = {
3464
+ width: size.height,
3465
+ height: size.width
3466
+ };
3467
+ }
3468
+ size.orientation = size.width > size.height ? 'landscape' : 'portrait';
3469
+ return size;
3470
+ }
3471
+ function normalizePageMargin(margin) {
3472
+ if (isNumber(margin)) {
3473
+ margin = {
3474
+ left: margin,
3475
+ right: margin,
3476
+ top: margin,
3477
+ bottom: margin
3478
+ };
3479
+ } else if (Array.isArray(margin)) {
3480
+ if (margin.length === 2) {
3481
+ margin = {
3482
+ left: margin[0],
3483
+ top: margin[1],
3484
+ right: margin[0],
3485
+ bottom: margin[1]
3486
+ };
3487
+ } else if (margin.length === 4) {
3488
+ margin = {
3489
+ left: margin[0],
3490
+ top: margin[1],
3491
+ right: margin[2],
3492
+ bottom: margin[3]
3493
+ };
3494
+ } else {
3495
+ throw new Error('Invalid pageMargins definition');
3496
+ }
3497
+ }
3498
+ return margin;
3499
+ }
3347
3500
  ;// ./src/PageElementWriter.js
3348
3501
 
3349
3502
 
3503
+
3504
+
3350
3505
  /**
3351
3506
  * An extended ElementWriter which can handle:
3352
3507
  * - page-breaks (it adds new pages when there's not enough space left),
@@ -3356,6 +3511,9 @@ function addPageItem(page, item, index) {
3356
3511
  * whole block will be rendered on the same page)
3357
3512
  */
3358
3513
  class PageElementWriter extends src_ElementWriter {
3514
+ /**
3515
+ * @param {DocumentContext} context
3516
+ */
3359
3517
  constructor(context) {
3360
3518
  super(context);
3361
3519
  this.transactionLevel = 0;
@@ -3411,6 +3569,16 @@ class PageElementWriter extends src_ElementWriter {
3411
3569
  y: this.context().y
3412
3570
  });
3413
3571
  }
3572
+ addPage(pageSize, pageOrientation, pageMargin) {
3573
+ let prevPage = this.page;
3574
+ let prevY = this.y;
3575
+ this.context().addPage(normalizePageSize(pageSize, pageOrientation), normalizePageMargin(pageMargin));
3576
+ this.emit('pageChanged', {
3577
+ prevPage: prevPage,
3578
+ prevY: prevY,
3579
+ y: this.context().y
3580
+ });
3581
+ }
3414
3582
  beginUnbreakableBlock(width, height) {
3415
3583
  if (this.transactionLevel++ === 0) {
3416
3584
  this.originalX = this.context().x;
@@ -4266,11 +4434,11 @@ class LayoutBuilder {
4266
4434
  this.linearNodeList = [];
4267
4435
  docStructure = this.docPreprocessor.preprocessDocument(docStructure);
4268
4436
  docStructure = this.docMeasure.measureDocument(docStructure);
4269
- this.writer = new src_PageElementWriter(new src_DocumentContext(this.pageSize, this.pageMargins));
4437
+ this.writer = new src_PageElementWriter(new src_DocumentContext());
4270
4438
  this.writer.context().addListener('pageAdded', () => {
4271
4439
  this.addBackground(background);
4272
4440
  });
4273
- this.addBackground(background);
4441
+ this.writer.addPage(this.pageSize, null, this.pageMargins);
4274
4442
  this.processNode(docStructure);
4275
4443
  this.addHeadersAndFooters(header, footer);
4276
4444
  if (watermark != null) {
@@ -4294,18 +4462,13 @@ class LayoutBuilder {
4294
4462
  context.backgroundLength[context.page] += pageBackground.positions.length;
4295
4463
  }
4296
4464
  }
4297
- addStaticRepeatable(headerOrFooter, sizeFunction) {
4298
- this.addDynamicRepeatable(() =>
4299
- // copy to new object
4300
- JSON.parse(JSON.stringify(headerOrFooter)), sizeFunction);
4301
- }
4302
4465
  addDynamicRepeatable(nodeGetter, sizeFunction) {
4303
4466
  let pages = this.writer.context().pages;
4304
4467
  for (let pageIndex = 0, l = pages.length; pageIndex < l; pageIndex++) {
4305
4468
  this.writer.context().page = pageIndex;
4306
4469
  let node = nodeGetter(pageIndex + 1, l, this.writer.context().pages[pageIndex].pageSize);
4307
4470
  if (node) {
4308
- let sizes = sizeFunction(this.writer.context().getCurrentPage().pageSize, this.pageMargins);
4471
+ let sizes = sizeFunction(this.writer.context().getCurrentPage().pageSize, this.writer.context().getCurrentPage().pageMargins);
4309
4472
  this.writer.beginUnbreakableBlock(sizes.width, sizes.height);
4310
4473
  node = this.docPreprocessor.preprocessDocument(node);
4311
4474
  this.processNode(this.docMeasure.measureDocument(node));
@@ -4326,15 +4489,11 @@ class LayoutBuilder {
4326
4489
  width: pageSize.width,
4327
4490
  height: pageMargins.bottom
4328
4491
  });
4329
- if (typeof header === 'function') {
4492
+ if (header) {
4330
4493
  this.addDynamicRepeatable(header, headerSizeFct);
4331
- } else if (header) {
4332
- this.addStaticRepeatable(header, headerSizeFct);
4333
4494
  }
4334
- if (typeof footer === 'function') {
4495
+ if (footer) {
4335
4496
  this.addDynamicRepeatable(footer, footerSizeFct);
4336
- } else if (footer) {
4337
- this.addStaticRepeatable(footer, footerSizeFct);
4338
4497
  }
4339
4498
  }
4340
4499
  addWatermark(watermark, pdfDocument, defaultStyle) {
@@ -4347,31 +4506,36 @@ class LayoutBuilder {
4347
4506
  // empty watermark text
4348
4507
  return;
4349
4508
  }
4350
- watermark.font = watermark.font || defaultStyle.font || 'Roboto';
4351
- watermark.fontSize = watermark.fontSize || 'auto';
4352
- watermark.color = watermark.color || 'black';
4353
- watermark.opacity = isNumber(watermark.opacity) ? watermark.opacity : 0.6;
4354
- watermark.bold = watermark.bold || false;
4355
- watermark.italics = watermark.italics || false;
4356
- watermark.angle = isValue(watermark.angle) ? watermark.angle : null;
4357
- if (watermark.angle === null) {
4358
- watermark.angle = Math.atan2(this.pageSize.height, this.pageSize.width) * -180 / Math.PI;
4359
- }
4360
- if (watermark.fontSize === 'auto') {
4361
- watermark.fontSize = getWatermarkFontSize(this.pageSize, watermark, pdfDocument);
4362
- }
4363
- let watermarkObject = {
4364
- text: watermark.text,
4365
- font: pdfDocument.provideFont(watermark.font, watermark.bold, watermark.italics),
4366
- fontSize: watermark.fontSize,
4367
- color: watermark.color,
4368
- opacity: watermark.opacity,
4369
- angle: watermark.angle
4370
- };
4371
- watermarkObject._size = getWatermarkSize(watermark, pdfDocument);
4372
4509
  let pages = this.writer.context().pages;
4373
4510
  for (let i = 0, l = pages.length; i < l; i++) {
4374
- pages[i].watermark = watermarkObject;
4511
+ pages[i].watermark = getWatermarkObject({
4512
+ ...watermark
4513
+ }, pages[i].pageSize, pdfDocument, defaultStyle);
4514
+ }
4515
+ function getWatermarkObject(watermark, pageSize, pdfDocument, defaultStyle) {
4516
+ watermark.font = watermark.font || defaultStyle.font || 'Roboto';
4517
+ watermark.fontSize = watermark.fontSize || 'auto';
4518
+ watermark.color = watermark.color || 'black';
4519
+ watermark.opacity = isNumber(watermark.opacity) ? watermark.opacity : 0.6;
4520
+ watermark.bold = watermark.bold || false;
4521
+ watermark.italics = watermark.italics || false;
4522
+ watermark.angle = isValue(watermark.angle) ? watermark.angle : null;
4523
+ if (watermark.angle === null) {
4524
+ watermark.angle = Math.atan2(pageSize.height, pageSize.width) * -180 / Math.PI;
4525
+ }
4526
+ if (watermark.fontSize === 'auto') {
4527
+ watermark.fontSize = getWatermarkFontSize(pageSize, watermark, pdfDocument);
4528
+ }
4529
+ let watermarkObject = {
4530
+ text: watermark.text,
4531
+ font: pdfDocument.provideFont(watermark.font, watermark.bold, watermark.italics),
4532
+ fontSize: watermark.fontSize,
4533
+ color: watermark.color,
4534
+ opacity: watermark.opacity,
4535
+ angle: watermark.angle
4536
+ };
4537
+ watermarkObject._size = getWatermarkSize(watermark, pdfDocument);
4538
+ return watermarkObject;
4375
4539
  }
4376
4540
  function getWatermarkSize(watermark, pdfDocument) {
4377
4541
  let textInlines = new src_TextInlines(pdfDocument);
@@ -5149,7 +5313,7 @@ var xmldoc_default = /*#__PURE__*/__webpack_require__.n(xmldoc);
5149
5313
  * @returns {?number}
5150
5314
  */
5151
5315
  const stripUnits = textVal => {
5152
- var n = parseFloat(textVal);
5316
+ let n = parseFloat(textVal);
5153
5317
  if (typeof n !== 'number' || isNaN(n)) {
5154
5318
  return undefined;
5155
5319
  }
@@ -5163,7 +5327,7 @@ const stripUnits = textVal => {
5163
5327
  * @returns {object}
5164
5328
  */
5165
5329
  const parseSVG = svgString => {
5166
- var doc;
5330
+ let doc;
5167
5331
  try {
5168
5332
  doc = new (xmldoc_default()).XmlDocument(svgString);
5169
5333
  } catch (err) {
@@ -5205,128 +5369,6 @@ class SVGMeasure {
5205
5369
  }
5206
5370
  }
5207
5371
  /* harmony default export */ var src_SVGMeasure = (SVGMeasure);
5208
- ;// ./src/standardPageSizes.js
5209
- /* harmony default export */ var standardPageSizes = ({
5210
- '4A0': [4767.87, 6740.79],
5211
- '2A0': [3370.39, 4767.87],
5212
- A0: [2383.94, 3370.39],
5213
- A1: [1683.78, 2383.94],
5214
- A2: [1190.55, 1683.78],
5215
- A3: [841.89, 1190.55],
5216
- A4: [595.28, 841.89],
5217
- A5: [419.53, 595.28],
5218
- A6: [297.64, 419.53],
5219
- A7: [209.76, 297.64],
5220
- A8: [147.40, 209.76],
5221
- A9: [104.88, 147.40],
5222
- A10: [73.70, 104.88],
5223
- B0: [2834.65, 4008.19],
5224
- B1: [2004.09, 2834.65],
5225
- B2: [1417.32, 2004.09],
5226
- B3: [1000.63, 1417.32],
5227
- B4: [708.66, 1000.63],
5228
- B5: [498.90, 708.66],
5229
- B6: [354.33, 498.90],
5230
- B7: [249.45, 354.33],
5231
- B8: [175.75, 249.45],
5232
- B9: [124.72, 175.75],
5233
- B10: [87.87, 124.72],
5234
- C0: [2599.37, 3676.54],
5235
- C1: [1836.85, 2599.37],
5236
- C2: [1298.27, 1836.85],
5237
- C3: [918.43, 1298.27],
5238
- C4: [649.13, 918.43],
5239
- C5: [459.21, 649.13],
5240
- C6: [323.15, 459.21],
5241
- C7: [229.61, 323.15],
5242
- C8: [161.57, 229.61],
5243
- C9: [113.39, 161.57],
5244
- C10: [79.37, 113.39],
5245
- RA0: [2437.80, 3458.27],
5246
- RA1: [1729.13, 2437.80],
5247
- RA2: [1218.90, 1729.13],
5248
- RA3: [864.57, 1218.90],
5249
- RA4: [609.45, 864.57],
5250
- SRA0: [2551.18, 3628.35],
5251
- SRA1: [1814.17, 2551.18],
5252
- SRA2: [1275.59, 1814.17],
5253
- SRA3: [907.09, 1275.59],
5254
- SRA4: [637.80, 907.09],
5255
- EXECUTIVE: [521.86, 756.00],
5256
- FOLIO: [612.00, 936.00],
5257
- LEGAL: [612.00, 1008.00],
5258
- LETTER: [612.00, 792.00],
5259
- TABLOID: [792.00, 1224.00]
5260
- });
5261
- ;// ./src/PageSize.js
5262
-
5263
-
5264
- function normalizePageSize(pageSize, pageOrientation) {
5265
- function isNeedSwapPageSizes(pageOrientation) {
5266
- if (isString(pageOrientation)) {
5267
- pageOrientation = pageOrientation.toLowerCase();
5268
- return pageOrientation === 'portrait' && size.width > size.height || pageOrientation === 'landscape' && size.width < size.height;
5269
- }
5270
- return false;
5271
- }
5272
- function pageSizeToWidthAndHeight(pageSize) {
5273
- if (isString(pageSize)) {
5274
- let size = standardPageSizes[pageSize.toUpperCase()];
5275
- if (!size) {
5276
- throw new Error(`Page size ${pageSize} not recognized`);
5277
- }
5278
- return {
5279
- width: size[0],
5280
- height: size[1]
5281
- };
5282
- }
5283
- return pageSize;
5284
- }
5285
-
5286
- // if pageSize.height is set to auto, set the height to infinity so there are no page breaks.
5287
- if (pageSize && pageSize.height === 'auto') {
5288
- pageSize.height = Infinity;
5289
- }
5290
- let size = pageSizeToWidthAndHeight(pageSize || 'A4');
5291
- if (isNeedSwapPageSizes(pageOrientation)) {
5292
- // swap page sizes
5293
- size = {
5294
- width: size.height,
5295
- height: size.width
5296
- };
5297
- }
5298
- size.orientation = size.width > size.height ? 'landscape' : 'portrait';
5299
- return size;
5300
- }
5301
- function normalizePageMargin(margin) {
5302
- if (isNumber(margin)) {
5303
- margin = {
5304
- left: margin,
5305
- right: margin,
5306
- top: margin,
5307
- bottom: margin
5308
- };
5309
- } else if (Array.isArray(margin)) {
5310
- if (margin.length === 2) {
5311
- margin = {
5312
- left: margin[0],
5313
- top: margin[1],
5314
- right: margin[0],
5315
- bottom: margin[1]
5316
- };
5317
- } else if (margin.length === 4) {
5318
- margin = {
5319
- left: margin[0],
5320
- top: margin[1],
5321
- right: margin[2],
5322
- bottom: margin[3]
5323
- };
5324
- } else {
5325
- throw new Error('Invalid pageMargins definition');
5326
- }
5327
- }
5328
- return margin;
5329
- }
5330
5372
  ;// ./src/TextDecorator.js
5331
5373
  const groupDecorations = line => {
5332
5374
  let groups = [];
@@ -5496,7 +5538,7 @@ const findFont = (fonts, requiredFonts, defaultFont) => {
5496
5538
  * @returns {number}
5497
5539
  */
5498
5540
  const offsetText = (y, inline) => {
5499
- var newY = y;
5541
+ let newY = y;
5500
5542
  if (inline.sup) {
5501
5543
  newY -= inline.fontSize * 0.75;
5502
5544
  }
@@ -5512,7 +5554,7 @@ class Renderer {
5512
5554
  }
5513
5555
  renderPages(pages) {
5514
5556
  this.pdfDocument._pdfMakePages = pages; // TODO: Why?
5515
- this.pdfDocument.addPage();
5557
+
5516
5558
  let totalItems = 0;
5517
5559
  if (this.progressCallback) {
5518
5560
  pages.forEach(page => {
@@ -5521,10 +5563,9 @@ class Renderer {
5521
5563
  }
5522
5564
  let renderedItems = 0;
5523
5565
  for (let i = 0; i < pages.length; i++) {
5524
- if (i > 0) {
5525
- this._updatePageOrientationInOptions(pages[i]);
5526
- this.pdfDocument.addPage(this.pdfDocument.options);
5527
- }
5566
+ this.pdfDocument.addPage({
5567
+ size: [pages[i].pageSize.width, pages[i].pageSize.height]
5568
+ });
5528
5569
  let page = pages[i];
5529
5570
  for (let ii = 0, il = page.items.length; ii < il; ii++) {
5530
5571
  let item = page.items[ii];
@@ -5847,14 +5888,6 @@ class Renderer {
5847
5888
  });
5848
5889
  this.pdfDocument.restore();
5849
5890
  }
5850
- _updatePageOrientationInOptions(currentPage) {
5851
- let previousPageOrientation = this.pdfDocument.options.size[0] > this.pdfDocument.options.size[1] ? 'landscape' : 'portrait';
5852
- if (currentPage.pageSize.orientation !== previousPageOrientation) {
5853
- let width = this.pdfDocument.options.size[0];
5854
- let height = this.pdfDocument.options.size[1];
5855
- this.pdfDocument.options.size = [height, width];
5856
- }
5857
- }
5858
5891
  }
5859
5892
  /* harmony default export */ var src_Renderer = (Renderer);
5860
5893
  ;// ./src/Printer.js
@@ -5866,6 +5899,7 @@ class Renderer {
5866
5899
 
5867
5900
 
5868
5901
 
5902
+
5869
5903
  /**
5870
5904
  * Printer which turns document definition into a pdf
5871
5905
  *
@@ -5923,6 +5957,12 @@ class PdfPrinter {
5923
5957
  docDefinition.attachments = docDefinition.attachments || {};
5924
5958
  docDefinition.pageMargins = isValue(docDefinition.pageMargins) ? docDefinition.pageMargins : 40;
5925
5959
  docDefinition.patterns = docDefinition.patterns || {};
5960
+ if (docDefinition.header && typeof docDefinition.header !== 'function') {
5961
+ docDefinition.header = convertToDynamicContent(docDefinition.header);
5962
+ }
5963
+ if (docDefinition.footer && typeof docDefinition.footer !== 'function') {
5964
+ docDefinition.footer = convertToDynamicContent(docDefinition.footer);
5965
+ }
5926
5966
  let pageSize = normalizePageSize(docDefinition.pageSize, docDefinition.pageOrientation);
5927
5967
  let pdfOptions = {
5928
5968
  size: [pageSize.width, pageSize.height],
@@ -6288,7 +6328,7 @@ class OutputDocument {
6288
6328
  }
6289
6329
  /* harmony default export */ var src_OutputDocument = (OutputDocument);
6290
6330
  // EXTERNAL MODULE: ./node_modules/file-saver/dist/FileSaver.min.js
6291
- var FileSaver_min = __webpack_require__(6200);
6331
+ var FileSaver_min = __webpack_require__(1676);
6292
6332
  ;// ./src/browser-extensions/OutputDocumentBrowser.js
6293
6333
 
6294
6334
 
@@ -26681,6 +26721,101 @@ util.inherits(DeflateRaw, Zlib);
26681
26721
  util.inherits(InflateRaw, Zlib);
26682
26722
  util.inherits(Unzip, Zlib);
26683
26723
 
26724
+ /***/ }),
26725
+
26726
+ /***/ 7802:
26727
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
26728
+
26729
+ "use strict";
26730
+
26731
+
26732
+ var bind = __webpack_require__(5049);
26733
+
26734
+ var $apply = __webpack_require__(3036);
26735
+ var $call = __webpack_require__(78);
26736
+ var $reflectApply = __webpack_require__(1909);
26737
+
26738
+ /** @type {import('./actualApply')} */
26739
+ module.exports = $reflectApply || bind.call($call, $apply);
26740
+
26741
+
26742
+ /***/ }),
26743
+
26744
+ /***/ 8619:
26745
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
26746
+
26747
+ "use strict";
26748
+
26749
+
26750
+ var bind = __webpack_require__(5049);
26751
+ var $apply = __webpack_require__(3036);
26752
+ var actualApply = __webpack_require__(7802);
26753
+
26754
+ /** @type {import('./applyBind')} */
26755
+ module.exports = function applyBind() {
26756
+ return actualApply(bind, $apply, arguments);
26757
+ };
26758
+
26759
+
26760
+ /***/ }),
26761
+
26762
+ /***/ 3036:
26763
+ /***/ (function(module) {
26764
+
26765
+ "use strict";
26766
+
26767
+
26768
+ /** @type {import('./functionApply')} */
26769
+ module.exports = Function.prototype.apply;
26770
+
26771
+
26772
+ /***/ }),
26773
+
26774
+ /***/ 78:
26775
+ /***/ (function(module) {
26776
+
26777
+ "use strict";
26778
+
26779
+
26780
+ /** @type {import('./functionCall')} */
26781
+ module.exports = Function.prototype.call;
26782
+
26783
+
26784
+ /***/ }),
26785
+
26786
+ /***/ 6688:
26787
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
26788
+
26789
+ "use strict";
26790
+
26791
+
26792
+ var bind = __webpack_require__(5049);
26793
+ var $TypeError = __webpack_require__(6785);
26794
+
26795
+ var $call = __webpack_require__(78);
26796
+ var $actualApply = __webpack_require__(7802);
26797
+
26798
+ /** @type {import('.')} */
26799
+ module.exports = function callBindBasic(args) {
26800
+ if (args.length < 1 || typeof args[0] !== 'function') {
26801
+ throw new $TypeError('a function is required');
26802
+ }
26803
+ return $actualApply(bind, $call, args);
26804
+ };
26805
+
26806
+
26807
+ /***/ }),
26808
+
26809
+ /***/ 1909:
26810
+ /***/ (function(module) {
26811
+
26812
+ "use strict";
26813
+
26814
+
26815
+ /** @type {import('./reflectApply')} */
26816
+ module.exports = typeof Reflect !== 'undefined' && Reflect && Reflect.apply;
26817
+
26818
+
26684
26819
  /***/ }),
26685
26820
 
26686
26821
  /***/ 7913:
@@ -26712,34 +26847,23 @@ module.exports = function callBoundIntrinsic(name, allowMissing) {
26712
26847
  "use strict";
26713
26848
 
26714
26849
 
26715
- var bind = __webpack_require__(5049);
26716
- var GetIntrinsic = __webpack_require__(8651);
26717
26850
  var setFunctionLength = __webpack_require__(6255);
26718
26851
 
26719
- var $TypeError = __webpack_require__(6785);
26720
- var $apply = GetIntrinsic('%Function.prototype.apply%');
26721
- var $call = GetIntrinsic('%Function.prototype.call%');
26722
- var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
26723
-
26724
26852
  var $defineProperty = __webpack_require__(6649);
26725
- var $max = GetIntrinsic('%Math.max%');
26853
+
26854
+ var callBindBasic = __webpack_require__(6688);
26855
+ var applyBind = __webpack_require__(8619);
26726
26856
 
26727
26857
  module.exports = function callBind(originalFunction) {
26728
- if (typeof originalFunction !== 'function') {
26729
- throw new $TypeError('a function is required');
26730
- }
26731
- var func = $reflectApply(bind, $call, arguments);
26858
+ var func = callBindBasic(arguments);
26859
+ var adjustedLength = originalFunction.length - (arguments.length - 1);
26732
26860
  return setFunctionLength(
26733
26861
  func,
26734
- 1 + $max(0, originalFunction.length - (arguments.length - 1)),
26862
+ 1 + (adjustedLength > 0 ? adjustedLength : 0),
26735
26863
  true
26736
26864
  );
26737
26865
  };
26738
26866
 
26739
- var applyBind = function applyBind() {
26740
- return $reflectApply(bind, $apply, arguments);
26741
- };
26742
-
26743
26867
  if ($defineProperty) {
26744
26868
  $defineProperty(module.exports, 'apply', { value: applyBind });
26745
26869
  } else {
@@ -26747,6 +26871,32 @@ if ($defineProperty) {
26747
26871
  }
26748
26872
 
26749
26873
 
26874
+ /***/ }),
26875
+
26876
+ /***/ 2774:
26877
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
26878
+
26879
+ "use strict";
26880
+
26881
+
26882
+ var GetIntrinsic = __webpack_require__(8651);
26883
+
26884
+ var callBind = __webpack_require__(6601);
26885
+
26886
+ // eslint-disable-next-line no-extra-parens
26887
+ var $indexOf = callBind(/** @type {typeof String.prototype.indexOf} */ (GetIntrinsic('String.prototype.indexOf')));
26888
+
26889
+ /** @type {import('.')} */
26890
+ module.exports = function callBoundIntrinsic(name, allowMissing) {
26891
+ // eslint-disable-next-line no-extra-parens
26892
+ var intrinsic = /** @type {Parameters<typeof callBind>[0]} */ (GetIntrinsic(name, !!allowMissing));
26893
+ if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
26894
+ return callBind(intrinsic);
26895
+ }
26896
+ return intrinsic;
26897
+ };
26898
+
26899
+
26750
26900
  /***/ }),
26751
26901
 
26752
26902
  /***/ 1613:
@@ -35697,7 +35847,7 @@ module.exports = function defineDataProperty(
35697
35847
 
35698
35848
  /***/ }),
35699
35849
 
35700
- /***/ 7802:
35850
+ /***/ 5421:
35701
35851
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
35702
35852
 
35703
35853
  "use strict";
@@ -35752,16 +35902,45 @@ module.exports = defineProperties;
35752
35902
 
35753
35903
  /***/ }),
35754
35904
 
35755
- /***/ 6649:
35905
+ /***/ 9302:
35756
35906
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
35757
35907
 
35758
35908
  "use strict";
35759
35909
 
35760
35910
 
35761
- var GetIntrinsic = __webpack_require__(8651);
35911
+ var callBind = __webpack_require__(6688);
35912
+ var gOPD = __webpack_require__(8109);
35913
+
35914
+ // eslint-disable-next-line no-extra-parens, no-proto
35915
+ var hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype;
35916
+
35917
+ // eslint-disable-next-line no-extra-parens
35918
+ var desc = hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__'));
35919
+
35920
+ var $Object = Object;
35921
+ var $getPrototypeOf = $Object.getPrototypeOf;
35922
+
35923
+ /** @type {import('./get')} */
35924
+ module.exports = desc && typeof desc.get === 'function'
35925
+ ? callBind([desc.get])
35926
+ : typeof $getPrototypeOf === 'function'
35927
+ ? /** @type {import('./get')} */ function getDunder(value) {
35928
+ // eslint-disable-next-line eqeqeq
35929
+ return $getPrototypeOf(value == null ? value : $Object(value));
35930
+ }
35931
+ : false;
35932
+
35933
+
35934
+ /***/ }),
35935
+
35936
+ /***/ 6649:
35937
+ /***/ (function(module) {
35938
+
35939
+ "use strict";
35940
+
35762
35941
 
35763
35942
  /** @type {import('.')} */
35764
- var $defineProperty = GetIntrinsic('%Object.defineProperty%', true) || false;
35943
+ var $defineProperty = Object.defineProperty || false;
35765
35944
  if ($defineProperty) {
35766
35945
  try {
35767
35946
  $defineProperty({}, 'a', { value: 1 });
@@ -35858,6 +36037,18 @@ module.exports = TypeError;
35858
36037
  module.exports = URIError;
35859
36038
 
35860
36039
 
36040
+ /***/ }),
36041
+
36042
+ /***/ 5846:
36043
+ /***/ (function(module) {
36044
+
36045
+ "use strict";
36046
+
36047
+
36048
+ /** @type {import('.')} */
36049
+ module.exports = Object;
36050
+
36051
+
35861
36052
  /***/ }),
35862
36053
 
35863
36054
  /***/ 4785:
@@ -36624,6 +36815,8 @@ module.exports = functionsHaveNames;
36624
36815
 
36625
36816
  var undefined;
36626
36817
 
36818
+ var $Object = __webpack_require__(5846);
36819
+
36627
36820
  var $Error = __webpack_require__(5293);
36628
36821
  var $EvalError = __webpack_require__(9055);
36629
36822
  var $RangeError = __webpack_require__(8888);
@@ -36632,6 +36825,12 @@ var $SyntaxError = __webpack_require__(7770);
36632
36825
  var $TypeError = __webpack_require__(6785);
36633
36826
  var $URIError = __webpack_require__(4055);
36634
36827
 
36828
+ var abs = __webpack_require__(716);
36829
+ var floor = __webpack_require__(7450);
36830
+ var max = __webpack_require__(3774);
36831
+ var min = __webpack_require__(7552);
36832
+ var pow = __webpack_require__(5874);
36833
+
36635
36834
  var $Function = Function;
36636
36835
 
36637
36836
  // eslint-disable-next-line consistent-return
@@ -36641,14 +36840,8 @@ var getEvalledConstructor = function (expressionSyntax) {
36641
36840
  } catch (e) {}
36642
36841
  };
36643
36842
 
36644
- var $gOPD = Object.getOwnPropertyDescriptor;
36645
- if ($gOPD) {
36646
- try {
36647
- $gOPD({}, '');
36648
- } catch (e) {
36649
- $gOPD = null; // this is IE 8, which has a broken gOPD
36650
- }
36651
- }
36843
+ var $gOPD = __webpack_require__(8109);
36844
+ var $defineProperty = __webpack_require__(6649);
36652
36845
 
36653
36846
  var throwTypeError = function () {
36654
36847
  throw new $TypeError();
@@ -36671,13 +36864,14 @@ var ThrowTypeError = $gOPD
36671
36864
  : throwTypeError;
36672
36865
 
36673
36866
  var hasSymbols = __webpack_require__(3257)();
36674
- var hasProto = __webpack_require__(5726)();
36867
+ var getDunderProto = __webpack_require__(9302);
36675
36868
 
36676
- var getProto = Object.getPrototypeOf || (
36677
- hasProto
36678
- ? function (x) { return x.__proto__; } // eslint-disable-line no-proto
36679
- : null
36680
- );
36869
+ var getProto = (typeof Reflect === 'function' && Reflect.getPrototypeOf)
36870
+ || $Object.getPrototypeOf
36871
+ || getDunderProto;
36872
+
36873
+ var $apply = __webpack_require__(3036);
36874
+ var $call = __webpack_require__(78);
36681
36875
 
36682
36876
  var needsEval = {};
36683
36877
 
@@ -36724,7 +36918,8 @@ var INTRINSICS = {
36724
36918
  '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()),
36725
36919
  '%Math%': Math,
36726
36920
  '%Number%': Number,
36727
- '%Object%': Object,
36921
+ '%Object%': $Object,
36922
+ '%Object.getOwnPropertyDescriptor%': $gOPD,
36728
36923
  '%parseFloat%': parseFloat,
36729
36924
  '%parseInt%': parseInt,
36730
36925
  '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
@@ -36750,7 +36945,16 @@ var INTRINSICS = {
36750
36945
  '%URIError%': $URIError,
36751
36946
  '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
36752
36947
  '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
36753
- '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
36948
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet,
36949
+
36950
+ '%Function.prototype.call%': $call,
36951
+ '%Function.prototype.apply%': $apply,
36952
+ '%Object.defineProperty%': $defineProperty,
36953
+ '%Math.abs%': abs,
36954
+ '%Math.floor%': floor,
36955
+ '%Math.max%': max,
36956
+ '%Math.min%': min,
36957
+ '%Math.pow%': pow
36754
36958
  };
36755
36959
 
36756
36960
  if (getProto) {
@@ -36845,11 +37049,11 @@ var LEGACY_ALIASES = {
36845
37049
 
36846
37050
  var bind = __webpack_require__(5049);
36847
37051
  var hasOwn = __webpack_require__(5215);
36848
- var $concat = bind.call(Function.call, Array.prototype.concat);
36849
- var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
36850
- var $replace = bind.call(Function.call, String.prototype.replace);
36851
- var $strSlice = bind.call(Function.call, String.prototype.slice);
36852
- var $exec = bind.call(Function.call, RegExp.prototype.exec);
37052
+ var $concat = bind.call($call, Array.prototype.concat);
37053
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
37054
+ var $replace = bind.call($call, String.prototype.replace);
37055
+ var $strSlice = bind.call($call, String.prototype.slice);
37056
+ var $exec = bind.call($call, RegExp.prototype.exec);
36853
37057
 
36854
37058
  /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
36855
37059
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
@@ -36981,6 +37185,18 @@ module.exports = function GetIntrinsic(name, allowMissing) {
36981
37185
  };
36982
37186
 
36983
37187
 
37188
+ /***/ }),
37189
+
37190
+ /***/ 805:
37191
+ /***/ (function(module) {
37192
+
37193
+ "use strict";
37194
+
37195
+
37196
+ /** @type {import('./gOPD')} */
37197
+ module.exports = Object.getOwnPropertyDescriptor;
37198
+
37199
+
36984
37200
  /***/ }),
36985
37201
 
36986
37202
  /***/ 8109:
@@ -36989,9 +37205,8 @@ module.exports = function GetIntrinsic(name, allowMissing) {
36989
37205
  "use strict";
36990
37206
 
36991
37207
 
36992
- var GetIntrinsic = __webpack_require__(8651);
36993
-
36994
- var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
37208
+ /** @type {import('.')} */
37209
+ var $gOPD = __webpack_require__(805);
36995
37210
 
36996
37211
  if ($gOPD) {
36997
37212
  try {
@@ -37035,29 +37250,6 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu
37035
37250
  module.exports = hasPropertyDescriptors;
37036
37251
 
37037
37252
 
37038
- /***/ }),
37039
-
37040
- /***/ 5726:
37041
- /***/ (function(module) {
37042
-
37043
- "use strict";
37044
-
37045
-
37046
- var test = {
37047
- __proto__: null,
37048
- foo: {}
37049
- };
37050
-
37051
- var $Object = Object;
37052
-
37053
- /** @type {import('.')} */
37054
- module.exports = function hasProto() {
37055
- // @ts-expect-error: TS errors on an inherited property for some reason
37056
- return { __proto__: test }.foo === test.foo
37057
- && !(test instanceof $Object);
37058
- };
37059
-
37060
-
37061
37253
  /***/ }),
37062
37254
 
37063
37255
  /***/ 3257:
@@ -37069,6 +37261,7 @@ module.exports = function hasProto() {
37069
37261
  var origSymbol = typeof Symbol !== 'undefined' && Symbol;
37070
37262
  var hasSymbolSham = __webpack_require__(5224);
37071
37263
 
37264
+ /** @type {import('.')} */
37072
37265
  module.exports = function hasNativeSymbols() {
37073
37266
  if (typeof origSymbol !== 'function') { return false; }
37074
37267
  if (typeof Symbol !== 'function') { return false; }
@@ -37087,11 +37280,13 @@ module.exports = function hasNativeSymbols() {
37087
37280
  "use strict";
37088
37281
 
37089
37282
 
37283
+ /** @type {import('./shams')} */
37090
37284
  /* eslint complexity: [2, 18], max-statements: [2, 33] */
37091
37285
  module.exports = function hasSymbols() {
37092
37286
  if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
37093
37287
  if (typeof Symbol.iterator === 'symbol') { return true; }
37094
37288
 
37289
+ /** @type {{ [k in symbol]?: unknown }} */
37095
37290
  var obj = {};
37096
37291
  var sym = Symbol('test');
37097
37292
  var symObj = Object(sym);
@@ -37110,7 +37305,7 @@ module.exports = function hasSymbols() {
37110
37305
 
37111
37306
  var symVal = 42;
37112
37307
  obj[sym] = symVal;
37113
- for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
37308
+ for (var _ in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
37114
37309
  if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
37115
37310
 
37116
37311
  if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
@@ -37121,7 +37316,8 @@ module.exports = function hasSymbols() {
37121
37316
  if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
37122
37317
 
37123
37318
  if (typeof Object.getOwnPropertyDescriptor === 'function') {
37124
- var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
37319
+ // eslint-disable-next-line no-extra-parens
37320
+ var descriptor = /** @type {PropertyDescriptor} */ (Object.getOwnPropertyDescriptor(obj, sym));
37125
37321
  if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
37126
37322
  }
37127
37323
 
@@ -40252,35 +40448,46 @@ if (typeof Object.create === 'function') {
40252
40448
 
40253
40449
 
40254
40450
  var hasToStringTag = __webpack_require__(6626)();
40255
- var callBound = __webpack_require__(7913);
40451
+ var callBound = __webpack_require__(2774);
40256
40452
 
40257
40453
  var $toString = callBound('Object.prototype.toString');
40258
40454
 
40455
+ /** @type {import('.')} */
40259
40456
  var isStandardArguments = function isArguments(value) {
40260
- if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) {
40457
+ if (
40458
+ hasToStringTag
40459
+ && value
40460
+ && typeof value === 'object'
40461
+ && Symbol.toStringTag in value
40462
+ ) {
40261
40463
  return false;
40262
40464
  }
40263
40465
  return $toString(value) === '[object Arguments]';
40264
40466
  };
40265
40467
 
40468
+ /** @type {import('.')} */
40266
40469
  var isLegacyArguments = function isArguments(value) {
40267
40470
  if (isStandardArguments(value)) {
40268
40471
  return true;
40269
40472
  }
40270
- return value !== null &&
40271
- typeof value === 'object' &&
40272
- typeof value.length === 'number' &&
40273
- value.length >= 0 &&
40274
- $toString(value) !== '[object Array]' &&
40275
- $toString(value.callee) === '[object Function]';
40473
+ return value !== null
40474
+ && typeof value === 'object'
40475
+ && 'length' in value
40476
+ && typeof value.length === 'number'
40477
+ && value.length >= 0
40478
+ && $toString(value) !== '[object Array]'
40479
+ && 'callee' in value
40480
+ && $toString(value.callee) === '[object Function]';
40276
40481
  };
40277
40482
 
40278
40483
  var supportsStandardArguments = (function () {
40279
40484
  return isStandardArguments(arguments);
40280
40485
  }());
40281
40486
 
40487
+ // @ts-expect-error TODO make this not error
40282
40488
  isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests
40283
40489
 
40490
+ /** @type {import('.')} */
40284
40491
  module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments;
40285
40492
 
40286
40493
 
@@ -40401,25 +40608,30 @@ module.exports = reflectApply
40401
40608
  "use strict";
40402
40609
 
40403
40610
 
40404
- var getDay = Date.prototype.getDay;
40611
+ var callBound = __webpack_require__(2774);
40612
+
40613
+ var getDay = callBound('Date.prototype.getDay');
40614
+ /** @type {import('.')} */
40405
40615
  var tryDateObject = function tryDateGetDayCall(value) {
40406
40616
  try {
40407
- getDay.call(value);
40617
+ getDay(value);
40408
40618
  return true;
40409
40619
  } catch (e) {
40410
40620
  return false;
40411
40621
  }
40412
40622
  };
40413
40623
 
40414
- var toStr = Object.prototype.toString;
40624
+ /** @type {(value: unknown) => string} */
40625
+ var toStr = callBound('Object.prototype.toString');
40415
40626
  var dateClass = '[object Date]';
40416
40627
  var hasToStringTag = __webpack_require__(6626)();
40417
40628
 
40629
+ /** @type {import('.')} */
40418
40630
  module.exports = function isDateObject(value) {
40419
40631
  if (typeof value !== 'object' || value === null) {
40420
40632
  return false;
40421
40633
  }
40422
- return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
40634
+ return hasToStringTag ? tryDateObject(value) : toStr(value) === dateClass;
40423
40635
  };
40424
40636
 
40425
40637
 
@@ -40493,7 +40705,7 @@ module.exports = function isNaN(value) {
40493
40705
 
40494
40706
 
40495
40707
  var callBind = __webpack_require__(6601);
40496
- var define = __webpack_require__(7802);
40708
+ var define = __webpack_require__(5421);
40497
40709
 
40498
40710
  var implementation = __webpack_require__(2621);
40499
40711
  var getPolyfill = __webpack_require__(1320);
@@ -40538,7 +40750,7 @@ module.exports = function getPolyfill() {
40538
40750
  "use strict";
40539
40751
 
40540
40752
 
40541
- var define = __webpack_require__(7802);
40753
+ var define = __webpack_require__(5421);
40542
40754
  var getPolyfill = __webpack_require__(1320);
40543
40755
 
40544
40756
  /* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */
@@ -40562,22 +40774,25 @@ module.exports = function shimNumberIsNaN() {
40562
40774
  "use strict";
40563
40775
 
40564
40776
 
40565
- var callBound = __webpack_require__(7913);
40777
+ var callBound = __webpack_require__(2774);
40566
40778
  var hasToStringTag = __webpack_require__(6626)();
40567
- var has;
40568
- var $exec;
40569
- var isRegexMarker;
40570
- var badStringifier;
40779
+ var hasOwn = __webpack_require__(5215);
40780
+ var gOPD = __webpack_require__(8109);
40781
+
40782
+ /** @type {import('.')} */
40783
+ var fn;
40571
40784
 
40572
40785
  if (hasToStringTag) {
40573
- has = callBound('Object.prototype.hasOwnProperty');
40574
- $exec = callBound('RegExp.prototype.exec');
40575
- isRegexMarker = {};
40786
+ /** @type {(receiver: ThisParameterType<typeof RegExp.prototype.exec>, ...args: Parameters<typeof RegExp.prototype.exec>) => ReturnType<typeof RegExp.prototype.exec>} */
40787
+ var $exec = callBound('RegExp.prototype.exec');
40788
+ /** @type {object} */
40789
+ var isRegexMarker = {};
40576
40790
 
40577
40791
  var throwRegexMarker = function () {
40578
40792
  throw isRegexMarker;
40579
40793
  };
40580
- badStringifier = {
40794
+ /** @type {{ toString(): never, valueOf(): never, [Symbol.toPrimitive]?(): never }} */
40795
+ var badStringifier = {
40581
40796
  toString: throwRegexMarker,
40582
40797
  valueOf: throwRegexMarker
40583
40798
  };
@@ -40585,32 +40800,37 @@ if (hasToStringTag) {
40585
40800
  if (typeof Symbol.toPrimitive === 'symbol') {
40586
40801
  badStringifier[Symbol.toPrimitive] = throwRegexMarker;
40587
40802
  }
40588
- }
40589
-
40590
- var $toString = callBound('Object.prototype.toString');
40591
- var gOPD = Object.getOwnPropertyDescriptor;
40592
- var regexClass = '[object RegExp]';
40593
40803
 
40594
- module.exports = hasToStringTag
40804
+ /** @type {import('.')} */
40805
+ // @ts-expect-error TS can't figure out that the $exec call always throws
40595
40806
  // eslint-disable-next-line consistent-return
40596
- ? function isRegex(value) {
40807
+ fn = function isRegex(value) {
40597
40808
  if (!value || typeof value !== 'object') {
40598
40809
  return false;
40599
40810
  }
40600
40811
 
40601
- var descriptor = gOPD(value, 'lastIndex');
40602
- var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
40812
+ // eslint-disable-next-line no-extra-parens
40813
+ var descriptor = /** @type {NonNullable<typeof gOPD>} */ (gOPD)(/** @type {{ lastIndex?: unknown }} */ (value), 'lastIndex');
40814
+ var hasLastIndexDataProperty = descriptor && hasOwn(descriptor, 'value');
40603
40815
  if (!hasLastIndexDataProperty) {
40604
40816
  return false;
40605
40817
  }
40606
40818
 
40607
40819
  try {
40608
- $exec(value, badStringifier);
40820
+ // eslint-disable-next-line no-extra-parens
40821
+ $exec(value, /** @type {string} */ (/** @type {unknown} */ (badStringifier)));
40609
40822
  } catch (e) {
40610
40823
  return e === isRegexMarker;
40611
40824
  }
40612
- }
40613
- : function isRegex(value) {
40825
+ };
40826
+ } else {
40827
+ /** @type {(receiver: ThisParameterType<typeof Object.prototype.toString>, ...args: Parameters<typeof Object.prototype.toString>) => ReturnType<typeof Object.prototype.toString>} */
40828
+ var $toString = callBound('Object.prototype.toString');
40829
+ /** @const @type {'[object RegExp]'} */
40830
+ var regexClass = '[object RegExp]';
40831
+
40832
+ /** @type {import('.')} */
40833
+ fn = function isRegex(value) {
40614
40834
  // In older browsers, typeof regex incorrectly returns 'function'
40615
40835
  if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
40616
40836
  return false;
@@ -40618,6 +40838,9 @@ module.exports = hasToStringTag
40618
40838
 
40619
40839
  return $toString(value) === regexClass;
40620
40840
  };
40841
+ }
40842
+
40843
+ module.exports = fn;
40621
40844
 
40622
40845
 
40623
40846
  /***/ }),
@@ -41019,6 +41242,66 @@ exports.parse = async;
41019
41242
  exports.parseSync = sync;
41020
41243
 
41021
41244
 
41245
+ /***/ }),
41246
+
41247
+ /***/ 716:
41248
+ /***/ (function(module) {
41249
+
41250
+ "use strict";
41251
+
41252
+
41253
+ /** @type {import('./abs')} */
41254
+ module.exports = Math.abs;
41255
+
41256
+
41257
+ /***/ }),
41258
+
41259
+ /***/ 7450:
41260
+ /***/ (function(module) {
41261
+
41262
+ "use strict";
41263
+
41264
+
41265
+ /** @type {import('./abs')} */
41266
+ module.exports = Math.floor;
41267
+
41268
+
41269
+ /***/ }),
41270
+
41271
+ /***/ 3774:
41272
+ /***/ (function(module) {
41273
+
41274
+ "use strict";
41275
+
41276
+
41277
+ /** @type {import('./max')} */
41278
+ module.exports = Math.max;
41279
+
41280
+
41281
+ /***/ }),
41282
+
41283
+ /***/ 7552:
41284
+ /***/ (function(module) {
41285
+
41286
+ "use strict";
41287
+
41288
+
41289
+ /** @type {import('./min')} */
41290
+ module.exports = Math.min;
41291
+
41292
+
41293
+ /***/ }),
41294
+
41295
+ /***/ 5874:
41296
+ /***/ (function(module) {
41297
+
41298
+ "use strict";
41299
+
41300
+
41301
+ /** @type {import('./pow')} */
41302
+ module.exports = Math.pow;
41303
+
41304
+
41022
41305
  /***/ }),
41023
41306
 
41024
41307
  /***/ 3249:
@@ -41054,7 +41337,7 @@ module.exports = function is(a, b) {
41054
41337
  "use strict";
41055
41338
 
41056
41339
 
41057
- var define = __webpack_require__(7802);
41340
+ var define = __webpack_require__(5421);
41058
41341
  var callBind = __webpack_require__(6601);
41059
41342
 
41060
41343
  var implementation = __webpack_require__(3249);
@@ -41096,7 +41379,7 @@ module.exports = function getPolyfill() {
41096
41379
 
41097
41380
 
41098
41381
  var getPolyfill = __webpack_require__(9636);
41099
- var define = __webpack_require__(7802);
41382
+ var define = __webpack_require__(5421);
41100
41383
 
41101
41384
  module.exports = function shimObjectIs() {
41102
41385
  var polyfill = getPolyfill();
@@ -47481,7 +47764,7 @@ module.exports = setFunctionName(function flags() {
47481
47764
  "use strict";
47482
47765
 
47483
47766
 
47484
- var define = __webpack_require__(7802);
47767
+ var define = __webpack_require__(5421);
47485
47768
  var callBind = __webpack_require__(6601);
47486
47769
 
47487
47770
  var implementation = __webpack_require__(3089);
@@ -47509,7 +47792,7 @@ module.exports = flagsBound;
47509
47792
 
47510
47793
  var implementation = __webpack_require__(3089);
47511
47794
 
47512
- var supportsDescriptors = (__webpack_require__(7802).supportsDescriptors);
47795
+ var supportsDescriptors = (__webpack_require__(5421).supportsDescriptors);
47513
47796
  var $gOPD = Object.getOwnPropertyDescriptor;
47514
47797
 
47515
47798
  module.exports = function getPolyfill() {
@@ -47554,7 +47837,7 @@ module.exports = function getPolyfill() {
47554
47837
  "use strict";
47555
47838
 
47556
47839
 
47557
- var supportsDescriptors = (__webpack_require__(7802).supportsDescriptors);
47840
+ var supportsDescriptors = (__webpack_require__(5421).supportsDescriptors);
47558
47841
  var getPolyfill = __webpack_require__(7844);
47559
47842
  var gOPD = Object.getOwnPropertyDescriptor;
47560
47843
  var defineProperty = Object.defineProperty;
@@ -54513,7 +54796,7 @@ module.exports = __webpack_require__(5349);
54513
54796
 
54514
54797
  /***/ }),
54515
54798
 
54516
- /***/ 6200:
54799
+ /***/ 1676:
54517
54800
  /***/ (function(module, exports, __webpack_require__) {
54518
54801
 
54519
54802
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(a,b){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (b),
@@ -67187,7 +67470,7 @@ module.exports = LineBreaker;
67187
67470
 
67188
67471
  /***/ }),
67189
67472
 
67190
- /***/ 4098:
67473
+ /***/ 9308:
67191
67474
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
67192
67475
 
67193
67476
  "use strict";
@@ -70077,7 +70360,7 @@ var EmbeddedFont = /*#__PURE__*/function (_PDFFont2) {
70077
70360
  } else {
70078
70361
  descriptor.data.FontFile2 = fontFile;
70079
70362
  }
70080
- if (this.document.subset) {
70363
+ if (this.document.subset && this.document.subset === 1) {
70081
70364
  var CIDSet = Buffer.from('FFFFFFFFC0', 'hex');
70082
70365
  var CIDSetRef = this.document.ref();
70083
70366
  CIDSetRef.write(CIDSet);
@@ -70698,12 +70981,11 @@ var TextMixin = {
70698
70981
  return text + ".";
70699
70982
  }
70700
70983
  };
70701
- var drawListItem = function drawListItem(listItem) {
70984
+ var drawListItem = function drawListItem(listItem, i) {
70702
70985
  var _this13 = this;
70703
70986
  wrapper = new LineWrapper(this, options);
70704
70987
  wrapper.on('line', this._line);
70705
70988
  level = 1;
70706
- var i = 0;
70707
70989
  wrapper.once('firstLine', function () {
70708
70990
  var item, itemType, labelType, bodyType;
70709
70991
  if (options.structParent) {
@@ -70765,7 +71047,7 @@ var TextMixin = {
70765
71047
  wrapper.wrap(listItem, options);
70766
71048
  };
70767
71049
  for (var i = 0; i < items.length; i++) {
70768
- drawListItem.call(this, items[i]);
71050
+ drawListItem.call(this, items[i], i);
70769
71051
  }
70770
71052
  return this;
70771
71053
  },
@@ -72474,7 +72756,7 @@ var AcroFormMixin = {
72474
72756
  },
72475
72757
  _resolveFont: function _resolveFont(options) {
72476
72758
  // add current font to document-level AcroForm dict if necessary
72477
- if (this._acroform.fonts[this._font.id] === null) {
72759
+ if (this._acroform.fonts[this._font.id] == null) {
72478
72760
  this._acroform.fonts[this._font.id] = this._font.ref();
72479
72761
  }
72480
72762
 
@@ -72545,11 +72827,13 @@ var AttachmentsMixin = {
72545
72827
  * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
72546
72828
  * * options.creationDate: override creation date
72547
72829
  * * options.modifiedDate: override modified date
72830
+ * * options.relationship: Relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'.
72548
72831
  * @returns filespec reference
72549
72832
  */
72550
72833
  file: function file(src) {
72551
72834
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
72552
72835
  options.name = options.name || src;
72836
+ options.relationship = options.relationship || 'Unspecified';
72553
72837
  var refBody = {
72554
72838
  Type: 'EmbeddedFile',
72555
72839
  Params: {}
@@ -72618,6 +72902,7 @@ var AttachmentsMixin = {
72618
72902
  // add filespec for embedded file
72619
72903
  var fileSpecBody = {
72620
72904
  Type: 'Filespec',
72905
+ AFRelationship: options.relationship,
72621
72906
  F: new String(options.name),
72622
72907
  EF: {
72623
72908
  F: ref
@@ -72632,13 +72917,20 @@ var AttachmentsMixin = {
72632
72917
  if (!options.hidden) {
72633
72918
  this.addNamedEmbeddedFile(options.name, filespec);
72634
72919
  }
72920
+
72921
+ // Add file to the catalogue to be PDF/A3 compliant
72922
+ if (this._root.data.AF) {
72923
+ this._root.data.AF.push(filespec);
72924
+ } else {
72925
+ this._root.data.AF = [filespec];
72926
+ }
72635
72927
  return filespec;
72636
72928
  }
72637
72929
  };
72638
72930
 
72639
72931
  /** check two embedded file metadata objects for equality */
72640
72932
  function isEqual(a, b) {
72641
- return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && a.Params.ModDate.getTime() === b.Params.ModDate.getTime();
72933
+ return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && (a.Params.ModDate === undefined && b.Params.ModDate === undefined || a.Params.ModDate.getTime() === b.Params.ModDate.getTime());
72642
72934
  }
72643
72935
  var PDFA = {
72644
72936
  initPDFA: function initPDFA(pSubset) {