@@ -369,6 +369,9 @@ import { jsPDF } from "../jspdf.js";
369369 * @param {Object } [config.fontSize] Integer fontSize to use (optional)
370370 * @param {Object } [config.padding] cell-padding in pt to use (optional)
371371 * @param {Object } [config.headerBackgroundColor] default is #c8c8c8 (optional)
372+ * @param {Object } [config.headerTextColor] default is #000 (optional)
373+ * @param {Object } [config.rowStart] callback to handle before print each row (optional)
374+ * @param {Object } [config.cellStart] callback to handle before print each cell (optional)
372375 * @returns {jsPDF } jsPDF-instance
373376 */
374377
@@ -401,7 +404,8 @@ import { jsPDF } from "../jspdf.js";
401404 config . margins ||
402405 Object . assign ( { width : this . getPageWidth ( ) } , NO_MARGINS ) ,
403406 padding = typeof config . padding === "number" ? config . padding : 3 ,
404- headerBackgroundColor = config . headerBackgroundColor || "#c8c8c8" ;
407+ headerBackgroundColor = config . headerBackgroundColor || "#c8c8c8" ,
408+ headerTextColor = config . headerTextColor || "#000" ;
405409
406410 _reset . call ( this ) ;
407411
@@ -410,6 +414,7 @@ import { jsPDF } from "../jspdf.js";
410414 this . internal . __cell__ . table_font_size = fontSize ;
411415 this . internal . __cell__ . padding = padding ;
412416 this . internal . __cell__ . headerBackgroundColor = headerBackgroundColor ;
417+ this . internal . __cell__ . headerTextColor = headerTextColor ;
413418 this . setFontSize ( fontSize ) ;
414419
415420 // Set header values
@@ -525,17 +530,37 @@ import { jsPDF } from "../jspdf.js";
525530 return pv ;
526531 } , { } ) ;
527532 for ( i = 0 ; i < data . length ; i += 1 ) {
533+ if ( "rowStart" in config && config . rowStart instanceof Function ) {
534+ config . rowStart (
535+ {
536+ row : i ,
537+ data : data [ i ]
538+ } ,
539+ this
540+ ) ;
541+ }
528542 var lineHeight = calculateLineHeight . call ( this , data [ i ] , columnWidths ) ;
529543
530544 for ( j = 0 ; j < headerNames . length ; j += 1 ) {
545+ var cellData = data [ i ] [ headerNames [ j ] ] ;
546+ if ( "cellStart" in config && config . cellStart instanceof Function ) {
547+ config . cellStart (
548+ {
549+ row : i ,
550+ col : j ,
551+ data : cellData
552+ } ,
553+ this
554+ ) ;
555+ }
531556 cell . call (
532557 this ,
533558 new Cell (
534559 x ,
535560 y ,
536561 columnWidths [ headerNames [ j ] ] ,
537562 lineHeight ,
538- data [ i ] [ headerNames [ j ] ] ,
563+ cellData ,
539564 i + 2 ,
540565 align [ headerNames [ j ] ]
541566 )
@@ -637,8 +662,11 @@ import { jsPDF } from "../jspdf.js";
637662 tempHeaderConf . push ( tableHeaderCell ) ;
638663 }
639664 tableHeaderCell . lineNumber = lineNumber ;
665+ var currentTextColor = this . getTextColor ( ) ;
666+ this . setTextColor ( this . internal . __cell__ . headerTextColor ) ;
640667 this . setFillColor ( this . internal . __cell__ . headerBackgroundColor ) ;
641668 cell . call ( this , tableHeaderCell ) ;
669+ this . setTextColor ( currentTextColor ) ;
642670 }
643671 if ( tempHeaderConf . length > 0 ) {
644672 this . setTableHeaderRow ( tempHeaderConf ) ;
0 commit comments