av6-pdf-engine 1.0.3 → 1.0.4

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/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import PDFDocument from 'pdfkit';
2
+
1
3
  interface SignatureBlock extends BaseBlock {
2
4
  type: "signature";
3
5
  height: number;
@@ -151,6 +153,7 @@ interface TextBlock extends BaseBlock {
151
153
  marginRight?: number;
152
154
  }
153
155
 
156
+ type PDFDoc = typeof PDFDocument;
154
157
  type Alignment = "left" | "right" | "center" | "justify";
155
158
  type Orientation = "horizontal" | "vertical";
156
159
  type Width = number | "*";
@@ -212,7 +215,7 @@ interface FontRegistration {
212
215
  src: string | Buffer;
213
216
  }
214
217
  interface CustomDocDefinition {
215
- pageSize?: PDFKit.PDFDocumentOptions["size"];
218
+ pageSize?: string;
216
219
  margins: PageMargins;
217
220
  /** Optional font registrations (custom TTF/OTF) */
218
221
  fonts?: FontRegistration[];
@@ -293,4 +296,4 @@ interface RenderEnv {
293
296
  declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
294
297
  declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
295
298
 
296
- export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, renderCustomPdf, renderCustomPdfToBuffer };
299
+ export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PDFDoc, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, renderCustomPdf, renderCustomPdfToBuffer };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import PDFDocument from 'pdfkit';
2
+
1
3
  interface SignatureBlock extends BaseBlock {
2
4
  type: "signature";
3
5
  height: number;
@@ -151,6 +153,7 @@ interface TextBlock extends BaseBlock {
151
153
  marginRight?: number;
152
154
  }
153
155
 
156
+ type PDFDoc = typeof PDFDocument;
154
157
  type Alignment = "left" | "right" | "center" | "justify";
155
158
  type Orientation = "horizontal" | "vertical";
156
159
  type Width = number | "*";
@@ -212,7 +215,7 @@ interface FontRegistration {
212
215
  src: string | Buffer;
213
216
  }
214
217
  interface CustomDocDefinition {
215
- pageSize?: PDFKit.PDFDocumentOptions["size"];
218
+ pageSize?: string;
216
219
  margins: PageMargins;
217
220
  /** Optional font registrations (custom TTF/OTF) */
218
221
  fonts?: FontRegistration[];
@@ -293,4 +296,4 @@ interface RenderEnv {
293
296
  declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
294
297
  declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
295
298
 
296
- export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, renderCustomPdf, renderCustomPdfToBuffer };
299
+ export { type Alignment, BARCODE_TYPES, type BarcodeBlock, type BarcodeType, type BaseBlock, type Block, type BuiltInFont, type ColumnsBlock, type CustomDocDefinition, type FontName, type FontRegistration, type FooterDef, type FooterInput, type HeaderDef, type ImageBlock, type InlineTextStyle, type KeyValueGridBlock, type KeyValueItem, type LineBlock, type Orientation, type PDFDoc, type PageBackgroundDef, type PageBreakBlock, type PageContext, type PageMargins, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableCell, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, renderCustomPdf, renderCustomPdfToBuffer };
package/dist/index.js CHANGED
@@ -235,9 +235,7 @@ var processKeyValueGridBlock = (doc, ctx, styles, block, y, env, computeColumnPi
235
235
  const widthForCols = Math.max(totalWidth - totalGapWidth, 1);
236
236
  let colWidths;
237
237
  if (block.columnWidths && block.columnWidths.length === colCount) {
238
- const safeWidths = block.columnWidths.map(
239
- (w) => w === void 0 ? "*" : w
240
- );
238
+ const safeWidths = block.columnWidths.map((w) => w === void 0 ? "*" : w);
241
239
  colWidths = computeColumnPixelWidths2(safeWidths, widthForCols);
242
240
  } else {
243
241
  const equal = widthForCols / colCount;
@@ -641,20 +639,9 @@ var processTextBlock = (doc, ctx, styles, block, y, env, ensureSpaceFor) => {
641
639
 
642
640
  // src/renderer-engine/utils/block-renderer.ts
643
641
  function createBlockRenderer(deps) {
644
- const {
645
- doc,
646
- ctx,
647
- styles,
648
- computeColumnPixelWidths: computeColumnPixelWidths2,
649
- finishPage: finishPage2,
650
- processSignatureBlock
651
- } = deps;
642
+ const { doc, ctx, styles, computeColumnPixelWidths: computeColumnPixelWidths2, finishPage: finishPage2, processSignatureBlock } = deps;
652
643
  const bottomLimitForContent = createBottomLimitForContent(doc, ctx);
653
- const ensureSpaceFor = createEnsureSpaceFor(
654
- ctx,
655
- bottomLimitForContent,
656
- finishPage2
657
- );
644
+ const ensureSpaceFor = createEnsureSpaceFor(ctx, bottomLimitForContent, finishPage2);
658
645
  const measureBlockHeight = createMeasureBlockHeight({
659
646
  doc,
660
647
  styles,
@@ -666,24 +653,9 @@ function createBlockRenderer(deps) {
666
653
  }
667
654
  switch (block.type) {
668
655
  case "text":
669
- return processTextBlock(
670
- doc,
671
- ctx,
672
- styles,
673
- block,
674
- y,
675
- env,
676
- ensureSpaceFor
677
- );
656
+ return processTextBlock(doc, ctx, styles, block, y, env, ensureSpaceFor);
678
657
  case "image":
679
- return processImageBlock(
680
- doc,
681
- ctx,
682
- block,
683
- y,
684
- env,
685
- ensureSpaceFor
686
- );
658
+ return processImageBlock(doc, ctx, block, y, env, ensureSpaceFor);
687
659
  case "qr": {
688
660
  const qb = block;
689
661
  const imageLike = {
@@ -702,14 +674,7 @@ function createBlockRenderer(deps) {
702
674
  case "barcode":
703
675
  return processBarcodeBlock(doc, ctx, block, y, env, ensureSpaceFor);
704
676
  case "line":
705
- return processLineBlock(
706
- doc,
707
- ctx,
708
- block,
709
- y,
710
- env,
711
- ensureSpaceFor
712
- );
677
+ return processLineBlock(doc, ctx, block, y, env, ensureSpaceFor);
713
678
  case "table":
714
679
  return processTableBlock(
715
680
  doc,
@@ -746,14 +711,10 @@ function createBlockRenderer(deps) {
746
711
  );
747
712
  case "signature":
748
713
  if (!env.allowPageBreak) {
749
- throw new Error(
750
- "Signature block is only allowed in main content flow."
751
- );
714
+ throw new Error("Signature block is only allowed in main content flow.");
752
715
  }
753
716
  if (y !== null) {
754
- throw new Error(
755
- "Signature block must be part of main flow, not drawn at explicit Y."
756
- );
717
+ throw new Error("Signature block must be part of main flow, not drawn at explicit Y.");
757
718
  }
758
719
  processSignatureBlock(block);
759
720
  return ctx.currentY;
@@ -832,13 +793,7 @@ function finishPage({
832
793
  }
833
794
  if (ctx.signatureBlock && ctx.signatureTopY !== null) {
834
795
  const env = contentEnv(doc);
835
- drawSignatureBlock(
836
- doc,
837
- ctx.signatureBlock,
838
- ctx.signatureTopY,
839
- env,
840
- renderBlockArray
841
- );
796
+ drawSignatureBlock(doc, ctx.signatureBlock, ctx.signatureTopY, env, renderBlockArray);
842
797
  }
843
798
  drawFooter(doc, def, ctx, footerBandHeight, renderBlockArray);
844
799
  if (addNewPage) {
@@ -1142,13 +1097,7 @@ function createMeasureBlockHeight(deps) {
1142
1097
  innerWidth,
1143
1098
  allowPageBreak: false
1144
1099
  };
1145
- const h = measureTableHeight(
1146
- doc,
1147
- b,
1148
- fakeEnv,
1149
- styles,
1150
- computeColumnPixelWidths2
1151
- );
1100
+ const h = measureTableHeight(doc, b, fakeEnv, styles, computeColumnPixelWidths2);
1152
1101
  return mt + h + mb;
1153
1102
  };
1154
1103
  const measureColumns = (b, env) => {
@@ -1238,14 +1187,8 @@ function createMeasureBlockHeight(deps) {
1238
1187
  const colWidth = colWidths[colIndex];
1239
1188
  let colHeight = 0;
1240
1189
  for (const item of col) {
1241
- const keyH = measureKVText(
1242
- { type: "text", text: item.key ?? "" },
1243
- colWidth
1244
- );
1245
- const valH = measureKVText(
1246
- { type: "text", text: item.value ?? "" },
1247
- colWidth
1248
- );
1190
+ const keyH = measureKVText({ type: "text", text: item.key ?? "" }, colWidth);
1191
+ const valH = measureKVText({ type: "text", text: item.value ?? "" }, colWidth);
1249
1192
  colHeight += keyH + keyValueGap + valH + rowGap;
1250
1193
  }
1251
1194
  if (colHeight > maxColHeight) maxColHeight = colHeight;
@@ -1260,16 +1203,10 @@ function createMeasureBlockHeight(deps) {
1260
1203
  if (!item) continue;
1261
1204
  const colWidth = colWidths[colIndex];
1262
1205
  const keyWidthPx = b.keyWidth === "*" ? Math.max(colWidth * baseKeyWidthRatio, 20) : b.keyWidth ?? 80;
1263
- const keyH = measureKVText(
1264
- { type: "text", text: item.key ?? "" },
1265
- keyWidthPx
1266
- );
1206
+ const keyH = measureKVText({ type: "text", text: item.key ?? "" }, keyWidthPx);
1267
1207
  const valueXInsideCol = keyWidthPx + (separatorText ? sepBoxWidth + 4 : 4);
1268
1208
  const valueWidth = Math.max(colWidth - valueXInsideCol, 1);
1269
- const valH = measureKVText(
1270
- { type: "text", text: item.value ?? "" },
1271
- valueWidth
1272
- );
1209
+ const valH = measureKVText({ type: "text", text: item.value ?? "" }, valueWidth);
1273
1210
  rowHeight = Math.max(rowHeight, Math.max(keyH, valH));
1274
1211
  }
1275
1212
  if (rowHeight > 0) totalHeight += rowHeight + rowGap;
@@ -1507,13 +1444,7 @@ function drawSignatureBlock(doc, block, y, env, renderBlockArray) {
1507
1444
  }
1508
1445
  doc.restore();
1509
1446
  }
1510
- function createProcessSignatureBlock({
1511
- doc,
1512
- ctx,
1513
- styles,
1514
- finishPage: finishPage2,
1515
- contentEnvFn
1516
- }) {
1447
+ function createProcessSignatureBlock({ doc, ctx, styles, finishPage: finishPage2, contentEnvFn }) {
1517
1448
  return (block) => {
1518
1449
  if (ctx.signatureBlock) {
1519
1450
  finishPage2(true);
@@ -1588,10 +1519,7 @@ function createProcessSignatureBlock({
1588
1519
  const tb = resolveTextBlock(styles, b);
1589
1520
  const localLeft2 = tb.marginLeft ?? 0;
1590
1521
  const localRight2 = tb.marginRight ?? 0;
1591
- const width = Math.max(
1592
- envForColumns.innerWidth - localLeft2 - localRight2,
1593
- 1
1594
- );
1522
+ const width = Math.max(envForColumns.innerWidth - localLeft2 - localRight2, 1);
1595
1523
  doc.fontSize(tb.fontSize ?? 10);
1596
1524
  const isBold = !!tb.bold;
1597
1525
  const isItalic = !!tb.italic;
@@ -1636,13 +1564,7 @@ function createProcessSignatureBlock({
1636
1564
  innerWidth: bandWidth - (t.marginLeft ?? 0) - (t.marginRight ?? 0),
1637
1565
  allowPageBreak: false
1638
1566
  };
1639
- return measureTableHeight(
1640
- doc,
1641
- t,
1642
- fakeEnv,
1643
- styles,
1644
- computeColumnPixelWidths
1645
- );
1567
+ return measureTableHeight(doc, t, fakeEnv, styles, computeColumnPixelWidths);
1646
1568
  }
1647
1569
  case "columns":
1648
1570
  return measureColumns(b);
@@ -1674,22 +1596,10 @@ function createProcessSignatureBlock({
1674
1596
  }
1675
1597
 
1676
1598
  // src/renderer-engine/utils/start-page-layout.ts
1677
- function createStartNewPageLayout({
1678
- doc,
1679
- def,
1680
- ctx,
1681
- headerBandHeight,
1682
- renderBlockArray
1683
- }) {
1599
+ function createStartNewPageLayout({ doc, def, ctx, headerBandHeight, renderBlockArray }) {
1684
1600
  return () => {
1685
1601
  drawPageBackground(doc, def.pageBackground);
1686
- drawHeader(
1687
- doc,
1688
- def,
1689
- headerBandHeight,
1690
- def.header ?? void 0,
1691
- renderBlockArray
1692
- );
1602
+ drawHeader(doc, def, headerBandHeight, def.header ?? void 0, renderBlockArray);
1693
1603
  const mode = def.watermark?.mode;
1694
1604
  if (def.watermark && !watermarkUsesLast(mode)) {
1695
1605
  drawWatermarkForPage(doc, def.watermark, ctx.pageNumber, false);
@@ -1708,14 +1618,7 @@ function watermarkUsesLast(mode) {
1708
1618
  return mode === "last" || mode === "firstLast" || mode === "exceptLast" || mode === "exceptFirstLast";
1709
1619
  }
1710
1620
  function drawWatermarkForPage(doc, watermark, pageNumber, isLast) {
1711
- const {
1712
- text,
1713
- opacity = 0.06,
1714
- fontSize = 60,
1715
- color = "gray",
1716
- angle = 45,
1717
- mode = "all"
1718
- } = watermark;
1621
+ const { text, opacity = 0.06, fontSize = 60, color = "gray", angle = 45, mode = "all" } = watermark;
1719
1622
  const shouldDraw = (() => {
1720
1623
  switch (mode) {
1721
1624
  case "all":
package/dist/index.mjs CHANGED
@@ -196,9 +196,7 @@ var processKeyValueGridBlock = (doc, ctx, styles, block, y, env, computeColumnPi
196
196
  const widthForCols = Math.max(totalWidth - totalGapWidth, 1);
197
197
  let colWidths;
198
198
  if (block.columnWidths && block.columnWidths.length === colCount) {
199
- const safeWidths = block.columnWidths.map(
200
- (w) => w === void 0 ? "*" : w
201
- );
199
+ const safeWidths = block.columnWidths.map((w) => w === void 0 ? "*" : w);
202
200
  colWidths = computeColumnPixelWidths2(safeWidths, widthForCols);
203
201
  } else {
204
202
  const equal = widthForCols / colCount;
@@ -602,20 +600,9 @@ var processTextBlock = (doc, ctx, styles, block, y, env, ensureSpaceFor) => {
602
600
 
603
601
  // src/renderer-engine/utils/block-renderer.ts
604
602
  function createBlockRenderer(deps) {
605
- const {
606
- doc,
607
- ctx,
608
- styles,
609
- computeColumnPixelWidths: computeColumnPixelWidths2,
610
- finishPage: finishPage2,
611
- processSignatureBlock
612
- } = deps;
603
+ const { doc, ctx, styles, computeColumnPixelWidths: computeColumnPixelWidths2, finishPage: finishPage2, processSignatureBlock } = deps;
613
604
  const bottomLimitForContent = createBottomLimitForContent(doc, ctx);
614
- const ensureSpaceFor = createEnsureSpaceFor(
615
- ctx,
616
- bottomLimitForContent,
617
- finishPage2
618
- );
605
+ const ensureSpaceFor = createEnsureSpaceFor(ctx, bottomLimitForContent, finishPage2);
619
606
  const measureBlockHeight = createMeasureBlockHeight({
620
607
  doc,
621
608
  styles,
@@ -627,24 +614,9 @@ function createBlockRenderer(deps) {
627
614
  }
628
615
  switch (block.type) {
629
616
  case "text":
630
- return processTextBlock(
631
- doc,
632
- ctx,
633
- styles,
634
- block,
635
- y,
636
- env,
637
- ensureSpaceFor
638
- );
617
+ return processTextBlock(doc, ctx, styles, block, y, env, ensureSpaceFor);
639
618
  case "image":
640
- return processImageBlock(
641
- doc,
642
- ctx,
643
- block,
644
- y,
645
- env,
646
- ensureSpaceFor
647
- );
619
+ return processImageBlock(doc, ctx, block, y, env, ensureSpaceFor);
648
620
  case "qr": {
649
621
  const qb = block;
650
622
  const imageLike = {
@@ -663,14 +635,7 @@ function createBlockRenderer(deps) {
663
635
  case "barcode":
664
636
  return processBarcodeBlock(doc, ctx, block, y, env, ensureSpaceFor);
665
637
  case "line":
666
- return processLineBlock(
667
- doc,
668
- ctx,
669
- block,
670
- y,
671
- env,
672
- ensureSpaceFor
673
- );
638
+ return processLineBlock(doc, ctx, block, y, env, ensureSpaceFor);
674
639
  case "table":
675
640
  return processTableBlock(
676
641
  doc,
@@ -707,14 +672,10 @@ function createBlockRenderer(deps) {
707
672
  );
708
673
  case "signature":
709
674
  if (!env.allowPageBreak) {
710
- throw new Error(
711
- "Signature block is only allowed in main content flow."
712
- );
675
+ throw new Error("Signature block is only allowed in main content flow.");
713
676
  }
714
677
  if (y !== null) {
715
- throw new Error(
716
- "Signature block must be part of main flow, not drawn at explicit Y."
717
- );
678
+ throw new Error("Signature block must be part of main flow, not drawn at explicit Y.");
718
679
  }
719
680
  processSignatureBlock(block);
720
681
  return ctx.currentY;
@@ -793,13 +754,7 @@ function finishPage({
793
754
  }
794
755
  if (ctx.signatureBlock && ctx.signatureTopY !== null) {
795
756
  const env = contentEnv(doc);
796
- drawSignatureBlock(
797
- doc,
798
- ctx.signatureBlock,
799
- ctx.signatureTopY,
800
- env,
801
- renderBlockArray
802
- );
757
+ drawSignatureBlock(doc, ctx.signatureBlock, ctx.signatureTopY, env, renderBlockArray);
803
758
  }
804
759
  drawFooter(doc, def, ctx, footerBandHeight, renderBlockArray);
805
760
  if (addNewPage) {
@@ -1103,13 +1058,7 @@ function createMeasureBlockHeight(deps) {
1103
1058
  innerWidth,
1104
1059
  allowPageBreak: false
1105
1060
  };
1106
- const h = measureTableHeight(
1107
- doc,
1108
- b,
1109
- fakeEnv,
1110
- styles,
1111
- computeColumnPixelWidths2
1112
- );
1061
+ const h = measureTableHeight(doc, b, fakeEnv, styles, computeColumnPixelWidths2);
1113
1062
  return mt + h + mb;
1114
1063
  };
1115
1064
  const measureColumns = (b, env) => {
@@ -1199,14 +1148,8 @@ function createMeasureBlockHeight(deps) {
1199
1148
  const colWidth = colWidths[colIndex];
1200
1149
  let colHeight = 0;
1201
1150
  for (const item of col) {
1202
- const keyH = measureKVText(
1203
- { type: "text", text: item.key ?? "" },
1204
- colWidth
1205
- );
1206
- const valH = measureKVText(
1207
- { type: "text", text: item.value ?? "" },
1208
- colWidth
1209
- );
1151
+ const keyH = measureKVText({ type: "text", text: item.key ?? "" }, colWidth);
1152
+ const valH = measureKVText({ type: "text", text: item.value ?? "" }, colWidth);
1210
1153
  colHeight += keyH + keyValueGap + valH + rowGap;
1211
1154
  }
1212
1155
  if (colHeight > maxColHeight) maxColHeight = colHeight;
@@ -1221,16 +1164,10 @@ function createMeasureBlockHeight(deps) {
1221
1164
  if (!item) continue;
1222
1165
  const colWidth = colWidths[colIndex];
1223
1166
  const keyWidthPx = b.keyWidth === "*" ? Math.max(colWidth * baseKeyWidthRatio, 20) : b.keyWidth ?? 80;
1224
- const keyH = measureKVText(
1225
- { type: "text", text: item.key ?? "" },
1226
- keyWidthPx
1227
- );
1167
+ const keyH = measureKVText({ type: "text", text: item.key ?? "" }, keyWidthPx);
1228
1168
  const valueXInsideCol = keyWidthPx + (separatorText ? sepBoxWidth + 4 : 4);
1229
1169
  const valueWidth = Math.max(colWidth - valueXInsideCol, 1);
1230
- const valH = measureKVText(
1231
- { type: "text", text: item.value ?? "" },
1232
- valueWidth
1233
- );
1170
+ const valH = measureKVText({ type: "text", text: item.value ?? "" }, valueWidth);
1234
1171
  rowHeight = Math.max(rowHeight, Math.max(keyH, valH));
1235
1172
  }
1236
1173
  if (rowHeight > 0) totalHeight += rowHeight + rowGap;
@@ -1468,13 +1405,7 @@ function drawSignatureBlock(doc, block, y, env, renderBlockArray) {
1468
1405
  }
1469
1406
  doc.restore();
1470
1407
  }
1471
- function createProcessSignatureBlock({
1472
- doc,
1473
- ctx,
1474
- styles,
1475
- finishPage: finishPage2,
1476
- contentEnvFn
1477
- }) {
1408
+ function createProcessSignatureBlock({ doc, ctx, styles, finishPage: finishPage2, contentEnvFn }) {
1478
1409
  return (block) => {
1479
1410
  if (ctx.signatureBlock) {
1480
1411
  finishPage2(true);
@@ -1549,10 +1480,7 @@ function createProcessSignatureBlock({
1549
1480
  const tb = resolveTextBlock(styles, b);
1550
1481
  const localLeft2 = tb.marginLeft ?? 0;
1551
1482
  const localRight2 = tb.marginRight ?? 0;
1552
- const width = Math.max(
1553
- envForColumns.innerWidth - localLeft2 - localRight2,
1554
- 1
1555
- );
1483
+ const width = Math.max(envForColumns.innerWidth - localLeft2 - localRight2, 1);
1556
1484
  doc.fontSize(tb.fontSize ?? 10);
1557
1485
  const isBold = !!tb.bold;
1558
1486
  const isItalic = !!tb.italic;
@@ -1597,13 +1525,7 @@ function createProcessSignatureBlock({
1597
1525
  innerWidth: bandWidth - (t.marginLeft ?? 0) - (t.marginRight ?? 0),
1598
1526
  allowPageBreak: false
1599
1527
  };
1600
- return measureTableHeight(
1601
- doc,
1602
- t,
1603
- fakeEnv,
1604
- styles,
1605
- computeColumnPixelWidths
1606
- );
1528
+ return measureTableHeight(doc, t, fakeEnv, styles, computeColumnPixelWidths);
1607
1529
  }
1608
1530
  case "columns":
1609
1531
  return measureColumns(b);
@@ -1635,22 +1557,10 @@ function createProcessSignatureBlock({
1635
1557
  }
1636
1558
 
1637
1559
  // src/renderer-engine/utils/start-page-layout.ts
1638
- function createStartNewPageLayout({
1639
- doc,
1640
- def,
1641
- ctx,
1642
- headerBandHeight,
1643
- renderBlockArray
1644
- }) {
1560
+ function createStartNewPageLayout({ doc, def, ctx, headerBandHeight, renderBlockArray }) {
1645
1561
  return () => {
1646
1562
  drawPageBackground(doc, def.pageBackground);
1647
- drawHeader(
1648
- doc,
1649
- def,
1650
- headerBandHeight,
1651
- def.header ?? void 0,
1652
- renderBlockArray
1653
- );
1563
+ drawHeader(doc, def, headerBandHeight, def.header ?? void 0, renderBlockArray);
1654
1564
  const mode = def.watermark?.mode;
1655
1565
  if (def.watermark && !watermarkUsesLast(mode)) {
1656
1566
  drawWatermarkForPage(doc, def.watermark, ctx.pageNumber, false);
@@ -1669,14 +1579,7 @@ function watermarkUsesLast(mode) {
1669
1579
  return mode === "last" || mode === "firstLast" || mode === "exceptLast" || mode === "exceptFirstLast";
1670
1580
  }
1671
1581
  function drawWatermarkForPage(doc, watermark, pageNumber, isLast) {
1672
- const {
1673
- text,
1674
- opacity = 0.06,
1675
- fontSize = 60,
1676
- color = "gray",
1677
- angle = 45,
1678
- mode = "all"
1679
- } = watermark;
1582
+ const { text, opacity = 0.06, fontSize = 60, color = "gray", angle = 45, mode = "all" } = watermark;
1680
1583
  const shouldDraw = (() => {
1681
1584
  switch (mode) {
1682
1585
  case "all":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-pdf-engine",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.mjs",
@@ -10,6 +10,7 @@
10
10
  "scripts": {
11
11
  "clean": "rm -rf dist",
12
12
  "build": "npm run clean && npm run format && tsup",
13
+ "prebuild": "tsc",
13
14
  "format": "prettier --write **/*.ts"
14
15
  },
15
16
  "dependencies": {