Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event for start printing row and cell #3039

Merged
merged 12 commits into from
Sep 10, 2021
Prev Previous commit
Next Next commit
Add the new API to the typings
  • Loading branch information
mojtaba-khallash committed Sep 9, 2021
commit ede2ee6f08563db686b58d401b2e1db7bbce53e6
24 changes: 15 additions & 9 deletions src/modules/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,21 +531,27 @@ import { jsPDF } from "../jspdf.js";
}, {});
for (i = 0; i < data.length; i += 1) {
if ("rowStart" in config && config.rowStart instanceof Function) {
config.rowStart({
row: i,
data: data[i]
});
config.rowStart(
{
row: i,
data: data[i]
},
this
);
}
var lineHeight = calculateLineHeight.call(this, data[i], columnWidths);

for (j = 0; j < headerNames.length; j += 1) {
var cellData = data[i][headerNames[j]];
if ("cellStart" in config && config.cellStart instanceof Function) {
config.cellStart({
row: i,
col: j,
data: cellData
});
config.cellStart(
{
row: i,
col: j,
data: cellData
},
this
);
}
cell.call(
this,
Expand Down
14 changes: 14 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,27 @@ declare module "jspdf" {
y: number;
}

export interface TableRowData {
row?: number;
data?: any[];
}

export interface TableCellData {
row?: number;
col?: number;
data?: any;
}

export interface TableConfig {
printHeaders?: boolean;
autoSize?: boolean;
margins?: number;
fontSize?: number;
padding?: number;
headerBackgroundColor?: string;
headerTextColor?: string;
rowStart?: (e: TableRowData, doc: jsPDF) => void;
cellStart?: (e: TableCellData, doc: jsPDF) => void;
css?: {
"font-size": number;
};
Expand Down