我正在使用jspdf autotable创建一个报告,该表是使用html绘制的,但是当行计数器大于5时,我需要一个新页面,因此我使用willDrawCell钩子函数来设置它。
if (idc>5) {
doc.addPage();
doc.setPage(1);
doc.text("OK");
}
doc.autoTable({html:"#listai",startY:60,startX:10,theme:"grid",styles:
{fontSize:12,valign:'middle',halign:'center',lineColor:[0,0,0],textColor:
[0,0,0]},columnStyles:{8:{textColor:
[255,255,255],cellPadding:0,cellWidth:0,fontSize:0.1,overflow:"hidden"}},didParseCell:(data)
=> {
if (data.section==='body' )
{if (data.row.index>0) {data.cell.styles.minCellHeight=14} else
{data.cell.styles.fillColor=200}
};
},willDrawCell: (data) => {if (data.row.index==5 && data.column.index==0)
{doc.setPage(2)};data.cell.styles.fillColor=255;},didDrawCell: (data) => {
if (data.section === 'body' && data.column.index === 0 && data.row.index>0) {
//var base64Img = document.getElementById('incfot').src//
var ss=data.row.index-1;
var base64Img = document.getElementById('mg'+ss).src;
var nx = data.cell.width/2-6;
ng+=14;
doc.addImage(base64Img, 'PNG', data.cell.x+nx , data.cell.y+1 , 12, 12);
}
}}) 在这个idc中有一个行计数器...所以我首先创建了一个页面,当我们绘制第5行时,我将文档更改为第2页。我发现了一个黑色单元格……

我曾尝试使用data.cell.fillColor=255更改填充颜色,但不起作用。
发布于 2021-06-03 22:50:58
我已经使用了doc.setFillColor(255,255,255)...
原始:(它不工作)
doc.setPage(2)};data.cell.styles.fillColor=255;
新版本:
doc.setPage(2)};doc.setFillColor(255,255,255);
https://stackoverflow.com/questions/67823078
复制相似问题