我使用 jsPDF
和 AutoTable
基于一个表格创建了一个 PDF 文档:
var doc = new jsPDF('p', 'pt');
//columns and rows are arrays created from the table content
doc.autoTable(columns, rows, {
drawRow: function (row) {
if (row.index == rows.length - 1) {
console.log('last row');
//TODO
}
},
pageBreak: 'avoid',
headerStyles: {
fillColor: [239, 154, 154],
textColor: [0, 0, 0],
halign: 'center'
},
bodyStyles: {
halign: 'center'
},
margin: {top: 60},
theme: 'striped'
});
doc.save('table.pdf');
我要做的是为最后一行表格设置不同的背景颜色。如上面的代码所示,我可以检测到最后一行正在被绘制,但我无法修改它。我尝试使用RGB值设置
row.fillColor
,但似乎没有效果。我还查看了示例,但没有找到任何可以帮助我解决这个问题的东西。有什么想法吗?
jspdf-autotable
标签。谢谢! - Simon Bengtsson