Plugin for jsPDF to write a table to pdf written with typescript.
const doc = new jsPDF({ unit: "px" });
const snapTable = new SnapTable(doc)
snapTable.writeTable(data);
const output = doc.output("datauri");
Supported Data:
{
head: ['Name', 'Email', 'Country'],
body: [
['Caitlin', '[email protected]', 'Sweden'],
['Gale', '[email protected]', 'Norway'],
['Roslyn', '[email protected]', 'Australia'],
['Reyna', '[email protected]', 'Ireland'],
['Sheree', '[email protected]', 'Germany'],
['Mueller', '[email protected]', 'United States of America'],
['Gray', '[email protected]', 'Sweden'],
['Fitzpatrick', '[email protected]', 'France'],
],
}
Individual cell can be modified with cell config object
{
head: ['Name', 'Email', 'Country'],
body: [
['Caitlin', '[email protected]', 'Sweden'],
['Gale', '[email protected]', 'Norway'],
['Roslyn', '[email protected]', 'Australia'],
['Reyna', '[email protected]', {
text: "Ireland",
background: "#F24436",
color: "#FFFFFF"
}],
['Sheree', '[email protected]', 'Germany'],
['Mueller', '[email protected]', 'United States of America'],
['Gray', {
text: "[email protected]",
background: "#FFFFFF",
color: "#FBC02D"
}, 'Sweden'],
['Fitzpatrick', '[email protected]', 'France'],
],
}
yarn install
yarn run storybook