av6-pdf-engine 1.1.0 → 2.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.
package/dist/index.d.mts CHANGED
@@ -48,8 +48,25 @@ interface PageBreakBlock extends BaseBlock {
48
48
  type: "pageBreak";
49
49
  }
50
50
 
51
+ type TableBorderSide = "top" | "right" | "bottom" | "left";
52
+ interface TableBorderStyle {
53
+ visible?: boolean;
54
+ color?: string;
55
+ width?: number;
56
+ dash?: number[];
57
+ }
58
+ type TableCellBorder = boolean | TableBorderStyle | Partial<Record<TableBorderSide, boolean | TableBorderStyle>>;
59
+ interface TableColumnStyle {
60
+ border?: TableCellBorder;
61
+ fillColor?: string;
62
+ }
63
+ interface TableRowStyle {
64
+ border?: TableCellBorder;
65
+ fillColor?: string;
66
+ }
51
67
  interface TableCell {
52
- text: string;
68
+ text?: string;
69
+ blocks?: Block[];
53
70
  italic?: boolean;
54
71
  underline?: boolean;
55
72
  link?: string;
@@ -67,22 +84,34 @@ interface TableCell {
67
84
  paddingRight?: number;
68
85
  paddingBottom?: number;
69
86
  paddingLeft?: number;
87
+ border?: TableCellBorder;
70
88
  }
71
89
  interface TableBlock extends BaseBlock {
72
90
  type: "table";
73
91
  headerRows?: number;
74
92
  widths: Width[];
75
- body: TableCell[][];
93
+ body: TableCell[][] | TableBodyIterable[] | Array<TableCell[] | TableBodyIterable>;
76
94
  layout?: {
77
95
  border?: "all" | "none";
78
96
  hLineColor?: string;
79
97
  vLineColor?: string;
98
+ borderColor?: string;
99
+ borderWidth?: number;
100
+ borderDash?: number[];
101
+ rowStyles?: Record<number, TableRowStyle>;
102
+ columnStyles?: Record<number, TableColumnStyle>;
80
103
  };
81
104
  lineGap?: number;
82
105
  marginTop?: number;
83
106
  marginBottom?: number;
84
107
  marginLeft?: number;
85
108
  marginRight?: number;
109
+ [key: string]: unknown;
110
+ }
111
+ interface TableBodyIterable {
112
+ isIterable: boolean;
113
+ iterableKey: string;
114
+ content: Array<TableCell>;
86
115
  }
87
116
  interface PlacedCell {
88
117
  cell: TableCell;
@@ -238,6 +267,8 @@ interface CustomDocDefinition {
238
267
  content: Block[];
239
268
  styles?: Record<string, StyleDef>;
240
269
  footer?: FooterInput;
270
+ /** Fallback image used when an image src fails to load or render. */
271
+ defaultImage?: string | Buffer;
241
272
  }
242
273
  interface HeaderDef {
243
274
  blocks: Block[];
@@ -265,6 +296,9 @@ type FooterInput = FooterDef | Block | Block[] | ((pageNumber: number, pageSize:
265
296
  }) => FooterDef | Block | Block[] | null | undefined);
266
297
  interface BaseBlock {
267
298
  visible?: boolean;
299
+ backgroundColor?: string;
300
+ backgroundImage?: string | Buffer;
301
+ backgroundOpacity?: number;
268
302
  }
269
303
  type Block = TextBlock | ImageBlock | QrCodeBlock | BarcodeBlock | LineBlock | ColumnsBlock | TableBlock | PageBreakBlock | KeyValueGridBlock | SignatureBlock;
270
304
 
@@ -349,7 +383,11 @@ declare function toPdfEngineError(cause: unknown, fallback: {
349
383
  retryable?: boolean;
350
384
  }): PdfEngineError;
351
385
 
386
+ declare const images: {
387
+ default: string;
388
+ };
389
+
352
390
  declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
353
391
  declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
354
392
 
355
- 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, PdfEngineError, PdfEngineErrorCode, type PlacedCell, 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, isPdfEngineError, renderCustomPdf, renderCustomPdfToBuffer, toPdfEngineError };
393
+ 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, PdfEngineError, PdfEngineErrorCode, type PlacedCell, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableBodyIterable, type TableBorderSide, type TableBorderStyle, type TableCell, type TableCellBorder, type TableColumnStyle, type TableRowStyle, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, images, isPdfEngineError, renderCustomPdf, renderCustomPdfToBuffer, toPdfEngineError };
package/dist/index.d.ts CHANGED
@@ -48,8 +48,25 @@ interface PageBreakBlock extends BaseBlock {
48
48
  type: "pageBreak";
49
49
  }
50
50
 
51
+ type TableBorderSide = "top" | "right" | "bottom" | "left";
52
+ interface TableBorderStyle {
53
+ visible?: boolean;
54
+ color?: string;
55
+ width?: number;
56
+ dash?: number[];
57
+ }
58
+ type TableCellBorder = boolean | TableBorderStyle | Partial<Record<TableBorderSide, boolean | TableBorderStyle>>;
59
+ interface TableColumnStyle {
60
+ border?: TableCellBorder;
61
+ fillColor?: string;
62
+ }
63
+ interface TableRowStyle {
64
+ border?: TableCellBorder;
65
+ fillColor?: string;
66
+ }
51
67
  interface TableCell {
52
- text: string;
68
+ text?: string;
69
+ blocks?: Block[];
53
70
  italic?: boolean;
54
71
  underline?: boolean;
55
72
  link?: string;
@@ -67,22 +84,34 @@ interface TableCell {
67
84
  paddingRight?: number;
68
85
  paddingBottom?: number;
69
86
  paddingLeft?: number;
87
+ border?: TableCellBorder;
70
88
  }
71
89
  interface TableBlock extends BaseBlock {
72
90
  type: "table";
73
91
  headerRows?: number;
74
92
  widths: Width[];
75
- body: TableCell[][];
93
+ body: TableCell[][] | TableBodyIterable[] | Array<TableCell[] | TableBodyIterable>;
76
94
  layout?: {
77
95
  border?: "all" | "none";
78
96
  hLineColor?: string;
79
97
  vLineColor?: string;
98
+ borderColor?: string;
99
+ borderWidth?: number;
100
+ borderDash?: number[];
101
+ rowStyles?: Record<number, TableRowStyle>;
102
+ columnStyles?: Record<number, TableColumnStyle>;
80
103
  };
81
104
  lineGap?: number;
82
105
  marginTop?: number;
83
106
  marginBottom?: number;
84
107
  marginLeft?: number;
85
108
  marginRight?: number;
109
+ [key: string]: unknown;
110
+ }
111
+ interface TableBodyIterable {
112
+ isIterable: boolean;
113
+ iterableKey: string;
114
+ content: Array<TableCell>;
86
115
  }
87
116
  interface PlacedCell {
88
117
  cell: TableCell;
@@ -238,6 +267,8 @@ interface CustomDocDefinition {
238
267
  content: Block[];
239
268
  styles?: Record<string, StyleDef>;
240
269
  footer?: FooterInput;
270
+ /** Fallback image used when an image src fails to load or render. */
271
+ defaultImage?: string | Buffer;
241
272
  }
242
273
  interface HeaderDef {
243
274
  blocks: Block[];
@@ -265,6 +296,9 @@ type FooterInput = FooterDef | Block | Block[] | ((pageNumber: number, pageSize:
265
296
  }) => FooterDef | Block | Block[] | null | undefined);
266
297
  interface BaseBlock {
267
298
  visible?: boolean;
299
+ backgroundColor?: string;
300
+ backgroundImage?: string | Buffer;
301
+ backgroundOpacity?: number;
268
302
  }
269
303
  type Block = TextBlock | ImageBlock | QrCodeBlock | BarcodeBlock | LineBlock | ColumnsBlock | TableBlock | PageBreakBlock | KeyValueGridBlock | SignatureBlock;
270
304
 
@@ -349,7 +383,11 @@ declare function toPdfEngineError(cause: unknown, fallback: {
349
383
  retryable?: boolean;
350
384
  }): PdfEngineError;
351
385
 
386
+ declare const images: {
387
+ default: string;
388
+ };
389
+
352
390
  declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
353
391
  declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
354
392
 
355
- 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, PdfEngineError, PdfEngineErrorCode, type PlacedCell, 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, isPdfEngineError, renderCustomPdf, renderCustomPdfToBuffer, toPdfEngineError };
393
+ 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, PdfEngineError, PdfEngineErrorCode, type PlacedCell, type QRErrorLevel, QR_ERROR_LEVEL, type QrCodeBlock, type RenderEnv, type SignatureBlock, type StyleDef, type StyleRef, type TableBlock, type TableBodyIterable, type TableBorderSide, type TableBorderStyle, type TableCell, type TableCellBorder, type TableColumnStyle, type TableRowStyle, type TextBlock, type WatermarkDef, type WatermarkMode, type Width, images, isPdfEngineError, renderCustomPdf, renderCustomPdfToBuffer, toPdfEngineError };