av6-pdf-engine 1.2.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,6 +84,7 @@ 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";
@@ -77,6 +95,11 @@ interface TableBlock extends BaseBlock {
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;
@@ -244,6 +267,8 @@ interface CustomDocDefinition {
244
267
  content: Block[];
245
268
  styles?: Record<string, StyleDef>;
246
269
  footer?: FooterInput;
270
+ /** Fallback image used when an image src fails to load or render. */
271
+ defaultImage?: string | Buffer;
247
272
  }
248
273
  interface HeaderDef {
249
274
  blocks: Block[];
@@ -271,6 +296,9 @@ type FooterInput = FooterDef | Block | Block[] | ((pageNumber: number, pageSize:
271
296
  }) => FooterDef | Block | Block[] | null | undefined);
272
297
  interface BaseBlock {
273
298
  visible?: boolean;
299
+ backgroundColor?: string;
300
+ backgroundImage?: string | Buffer;
301
+ backgroundOpacity?: number;
274
302
  }
275
303
  type Block = TextBlock | ImageBlock | QrCodeBlock | BarcodeBlock | LineBlock | ColumnsBlock | TableBlock | PageBreakBlock | KeyValueGridBlock | SignatureBlock;
276
304
 
@@ -355,7 +383,11 @@ declare function toPdfEngineError(cause: unknown, fallback: {
355
383
  retryable?: boolean;
356
384
  }): PdfEngineError;
357
385
 
386
+ declare const images: {
387
+ default: string;
388
+ };
389
+
358
390
  declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
359
391
  declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
360
392
 
361
- 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 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,6 +84,7 @@ 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";
@@ -77,6 +95,11 @@ interface TableBlock extends BaseBlock {
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;
@@ -244,6 +267,8 @@ interface CustomDocDefinition {
244
267
  content: Block[];
245
268
  styles?: Record<string, StyleDef>;
246
269
  footer?: FooterInput;
270
+ /** Fallback image used when an image src fails to load or render. */
271
+ defaultImage?: string | Buffer;
247
272
  }
248
273
  interface HeaderDef {
249
274
  blocks: Block[];
@@ -271,6 +296,9 @@ type FooterInput = FooterDef | Block | Block[] | ((pageNumber: number, pageSize:
271
296
  }) => FooterDef | Block | Block[] | null | undefined);
272
297
  interface BaseBlock {
273
298
  visible?: boolean;
299
+ backgroundColor?: string;
300
+ backgroundImage?: string | Buffer;
301
+ backgroundOpacity?: number;
274
302
  }
275
303
  type Block = TextBlock | ImageBlock | QrCodeBlock | BarcodeBlock | LineBlock | ColumnsBlock | TableBlock | PageBreakBlock | KeyValueGridBlock | SignatureBlock;
276
304
 
@@ -355,7 +383,11 @@ declare function toPdfEngineError(cause: unknown, fallback: {
355
383
  retryable?: boolean;
356
384
  }): PdfEngineError;
357
385
 
386
+ declare const images: {
387
+ default: string;
388
+ };
389
+
358
390
  declare function renderCustomPdf(def: CustomDocDefinition, outputPath: string): Promise<void>;
359
391
  declare function renderCustomPdfToBuffer(def: CustomDocDefinition): Promise<Buffer>;
360
392
 
361
- 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 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 };