在jspd-autotable中,是否可以在每一行下面添加一条线?即不是在每个单元格周围加边框,而是在每个单元格底部加边框。
在jspd-autotable中,是否可以在每一行下面添加一条线?即不是在每个单元格周围加边框,而是在每个单元格底部加边框。
doc.autoTable({
willDrawCell: function(data) {
// add borders around the head cells
if (data.row.section === "head") {
doc.setDrawColor(0, 0, 0); // set the border color
doc.setLineWidth(0.5); // set the border with
// draw bottom border
doc.line(
data.cell.x,
data.cell.y + data.cell.height,
data.cell.x + data.cell.width,
data.cell.y + data.cell.height
);
// draw top border
doc.line(
data.cell.x + data.cell.width,
data.cell.y,
data.cell.x,
data.cell.y
);
// draw left border
doc.line(
data.cell.x,
data.cell.y + data.cell.height,
data.cell.x,
data.cell.y
);
// draw right border
doc.line(
data.cell.x + data.cell.width,
data.cell.y,
data.cell.x + data.cell.width,
data.cell.y + data.cell.height
);
}
},
});
也可以为某些特定的单元格添加边框:
doc.autoTable({
willDrawCell: function(data) {
// add borders around the head cells
if (data.row.section === "head" && data.column.dataKey === "qty") {
doc.setDrawColor(255, 255, 0); // set the border color
doc.setLineWidth(0.5); // set the border with
// draw bottom border
doc.line(
data.cell.x,
data.cell.y,
data.cell.x + data.cell.width,
data.cell.y
);
}
},
});
参考: https://github.com/simonbengtsson/jsPDF-AutoTable/issues/651#issuecomment-626272061
这个问题可能与你的页面中使用的字体有关。如果字体在PDF生成期间不可用,那么将使用默认字体替换它们。因此,您需要确保在生成PDF时使用的所有字体都已正确加载。