@@ -344,6 +344,28 @@ declare namespace PDFKit.Mixins {
344344
345345 type BoundingBox = [ number , number , number , number ] ;
346346
347+ type SizeUnits = 'em' | 'in' | 'px' | 'cm' | 'mm' | 'pc' | 'ex' | 'ch' | 'rem' | 'vw' | 'vmin' | 'vmax' | '%' | 'pt' ;
348+
349+ type Size = number | `${number } ` | `${number } ${SizeUnits } `;
350+
351+ type Wideness = Size | boolean ;
352+
353+ type Sides < T > = T | [ T , T ] | [ T , T , T , T ] | SlightlyExpandedSides < T > | ExpandedSides < T > ;
354+
355+ type PartialSides < T > = T | [ T , T ] | [ T , T , T , T ] | Partial < SlightlyExpandedSides < T > > | Partial < ExpandedSides < T > > ;
356+
357+ interface SlightlyExpandedSides < T > {
358+ vertical : T ;
359+ horizontal : T ;
360+ }
361+
362+ interface ExpandedSides < T > {
363+ top : T ;
364+ right : T ;
365+ bottom : T ;
366+ left : T ;
367+ }
368+
347369 interface PDFColor {
348370 fillColor ( color : ColorValue , opacity ?: number ) : this;
349371 strokeColor ( color : ColorValue , opacity ?: number ) : this;
@@ -361,6 +383,7 @@ declare namespace PDFKit.Mixins {
361383 font ( src : PDFFontSource , size ?: number ) : this;
362384 font ( src : PDFFontSource , family : string , size ?: number ) : this;
363385 fontSize ( size : number ) : this;
386+ sizeToPoint ( size : Size , defaultValue ?: number , page ?: PDFPage , percentageWidth ?: number ) : number ;
364387 currentLineHeight ( includeGap ?: boolean ) : number ;
365388 /** Helpful method to give a font an alias, eg: `registerFont('bold', './Roboto.ttf')` */
366389 registerFont (
@@ -399,22 +422,26 @@ declare namespace PDFKit.Mixins {
399422 }
400423
401424 interface CellStyle {
425+ /** The text stroke (default 0) */
426+ textStroke ?: number | boolean ;
427+ /** Sets the text stroke color of the cells text (default black) */
428+ textStrokeColor ?: ColorValue ;
429+ /** Sets the text color of the cells text (default black) */
430+ textColor ?: ColorValue ;
402431 /** The border for the cell (default 1pt) */
403- border ?: boolean | number | Array < boolean | number > | {
404- top ?: number ;
405- right ?: number ;
406- bottom ?: number ;
407- left ?: number ;
408- } | undefined ;
432+ border ?: PartialSides < Wideness > | undefined ;
409433 /** The border colors for the cell (default black) */
410- borderColor ?: string | Array < string > | {
411- top ?: ColorValue ;
412- right ?: ColorValue ;
413- bottom ?: ColorValue ;
414- left ?: ColorValue ;
415- } ;
434+ borderColor ?: PartialSides < ColorValue > ;
416435 /** Set the background color of the cell */
417436 backgroundColor ?: ColorValue ;
437+ /** The padding for the cell (default 0.25em) */
438+ padding ?: Sides < Wideness > ;
439+ /** The alignment of the cell text (default {x: 'left', y: 'top'}) */
440+ align ?: "center" | ExpandedAlign ;
441+ /** Sets any text options you wish to provide (such as rotation) */
442+ textOptions ?: TextOptions ;
443+ /** Whether to show the debug lines for the cell (default false) */
444+ debug ?: boolean ;
418445 }
419446
420447 interface TableOptions {
@@ -423,9 +450,9 @@ declare namespace PDFKit.Mixins {
423450 /** The maximum width the table can expand to (defaults to the remaining content width (offset from the tables position)) */
424451 maxWidth ?: number ;
425452 /** Column definitions of the table. (default auto) */
426- columnStyles ?: number | Array < number | string > | CellStyle | ( ( row : number ) => number | CellStyle | undefined ) ;
453+ columnStyles ?: number | Array < number | string > | ColumnStyle | ( ( row : number ) => number | ColumnStyle | undefined ) ;
427454 /** Row definitions of the table. (default *) */
428- rowStyles ?: number | Array < number | string > | CellStyle | ( ( row : number ) => number | CellStyle | undefined ) ;
455+ rowStyles ?: number | Array < number | string > | RowStyle | ( ( row : number ) => number | RowStyle | undefined ) ;
429456 /** Defaults to apply to every cell */
430457 defaultStyle ?:
431458 & ( number | Array < number | string > | CellStyle | ( ( row : number ) => number | CellStyle | undefined ) )
@@ -451,27 +478,13 @@ declare namespace PDFKit.Mixins {
451478 rowSpan ?: number ;
452479 /** How many columns this cell covers, follows the same logic as HTML colspan */
453480 colSpan ?: number ;
454- /** The padding for the cell (default 0.25em) */
455- padding ?: string ;
456481 /** Font options for the cell */
457- font ?: any ;
458- /** The alignment of the cell text (default {x: 'left', y: 'top'}) */
459- align ?: "center" | ExpandedAlign ;
460- /** The text stroke (default 0) */
461- textStroke ?: number | boolean ;
462- /** Sets the text stroke color of the cells text (default black) */
463- textStrokeColor ?: ColorValue ;
464- /** Sets the text color of the cells text (default black) */
465- textColor ?: ColorValue ;
482+ font ?: { src ?: PDFFontSource ; family ?: string ; size ?: number ; } ;
466483 /** Sets the cell type (for accessibility) (default TD) */
467- type ?: string ;
468- /** Sets any text options you wish to provide (such as rotation) */
469- textOptions ?: TextOptions ;
470- /** Whether to show the debug lines for the cell (default false) */
471- debug ?: boolean ;
484+ type ?: 'TD' | 'TH' ;
472485 }
473486
474- interface ColumnOptions extends CellOptions {
487+ interface ColumnStyle extends CellStyle {
475488 /** The width of the column (default *) */
476489 width ?: string | number ;
477490 /** The minimum width of the column (default 0) */
@@ -480,7 +493,7 @@ declare namespace PDFKit.Mixins {
480493 maxWidth ?: string | number ;
481494 }
482495
483- interface RowOptions extends CellOptions {
496+ interface RowBase {
484497 /** The height of the row (default auto) */
485498 height ?: string | number ;
486499 /** The minimum height of the row (default 0) */
@@ -489,6 +502,10 @@ declare namespace PDFKit.Mixins {
489502 maxHeight ?: string | number ;
490503 }
491504
505+ interface RowStyle extends CellStyle , RowBase { }
506+
507+ interface RowOptions extends CellOptions , RowBase { }
508+
492509 interface PDFTableObject {
493510 /** Add a row of data (null and undefined are not rendered) */
494511 row ( data : Array < string | undefined | null | RowOptions > ) : this;
@@ -803,8 +820,8 @@ declare namespace PDFKit {
803820 pdfVersion ?: "1.3" | "1.4" | "1.5" | "1.6" | "1.7" | "1.7ext3" | undefined ;
804821 autoFirstPage ?: boolean | undefined ;
805822 size ?: number [ ] | string | undefined ;
806- margin ?: number | undefined ;
807- margins ?: { top : number ; left : number ; bottom : number ; right : number } | undefined ;
823+ margin ?: PDFKit . Mixins . Size | undefined ;
824+ margins ?: PDFKit . Mixins . ExpandedSides < PDFKit . Mixins . Size > | undefined ;
808825 layout ?: "portrait" | "landscape" | undefined ;
809826 font ?: string | undefined ;
810827
@@ -925,7 +942,7 @@ declare namespace PDFKit {
925942 interface PDFPage {
926943 size : string ;
927944 layout : string ;
928- margins : { top : number ; left : number ; bottom : number ; right : number } ;
945+ margins : PDFKit . Mixins . ExpandedSides < number > ;
929946 width : number ;
930947 height : number ;
931948 document : PDFDocument ;
0 commit comments