@@ -369,6 +369,9 @@ import { jsPDF } from "../jspdf.js";
369
369
* @param {Object } [config.fontSize] Integer fontSize to use (optional)
370
370
* @param {Object } [config.padding] cell-padding in pt to use (optional)
371
371
* @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)
372
375
* @returns {jsPDF } jsPDF-instance
373
376
*/
374
377
@@ -401,7 +404,8 @@ import { jsPDF } from "../jspdf.js";
401
404
config . margins ||
402
405
Object . assign ( { width : this . getPageWidth ( ) } , NO_MARGINS ) ,
403
406
padding = typeof config . padding === "number" ? config . padding : 3 ,
404
- headerBackgroundColor = config . headerBackgroundColor || "#c8c8c8" ;
407
+ headerBackgroundColor = config . headerBackgroundColor || "#c8c8c8" ,
408
+ headerTextColor = config . headerTextColor || "#000" ;
405
409
406
410
_reset . call ( this ) ;
407
411
@@ -410,6 +414,7 @@ import { jsPDF } from "../jspdf.js";
410
414
this . internal . __cell__ . table_font_size = fontSize ;
411
415
this . internal . __cell__ . padding = padding ;
412
416
this . internal . __cell__ . headerBackgroundColor = headerBackgroundColor ;
417
+ this . internal . __cell__ . headerTextColor = headerTextColor ;
413
418
this . setFontSize ( fontSize ) ;
414
419
415
420
// Set header values
@@ -525,17 +530,37 @@ import { jsPDF } from "../jspdf.js";
525
530
return pv ;
526
531
} , { } ) ;
527
532
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
+ }
528
542
var lineHeight = calculateLineHeight . call ( this , data [ i ] , columnWidths ) ;
529
543
530
544
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
+ }
531
556
cell . call (
532
557
this ,
533
558
new Cell (
534
559
x ,
535
560
y ,
536
561
columnWidths [ headerNames [ j ] ] ,
537
562
lineHeight ,
538
- data [ i ] [ headerNames [ j ] ] ,
563
+ cellData ,
539
564
i + 2 ,
540
565
align [ headerNames [ j ] ]
541
566
)
@@ -637,8 +662,11 @@ import { jsPDF } from "../jspdf.js";
637
662
tempHeaderConf . push ( tableHeaderCell ) ;
638
663
}
639
664
tableHeaderCell . lineNumber = lineNumber ;
665
+ var currentTextColor = this . getTextColor ( ) ;
666
+ this . setTextColor ( this . internal . __cell__ . headerTextColor ) ;
640
667
this . setFillColor ( this . internal . __cell__ . headerBackgroundColor ) ;
641
668
cell . call ( this , tableHeaderCell ) ;
669
+ this . setTextColor ( currentTextColor ) ;
642
670
}
643
671
if ( tempHeaderConf . length > 0 ) {
644
672
this . setTableHeaderRow ( tempHeaderConf ) ;
0 commit comments