我正在使用jsPDF和Autotable将表格导出为PDF。在某些表上,我在最后一列使用了一个编辑选项。当我在这些表上导出PDF时,还会打印最后一个看起来很丑的td。如何忽略一个表中的特定列?现在,我使用下面的代码创建PDF:
function CreatePdf(title, orientation, fileName, base64Img, tableName) {
var doc = new jsPDF(orientation);
var totalPagesExp = "{total_pages_count_string}";
const pageContent = function (data) {
// header
doc.setFontSize(14);
doc.setTextColor(40);
doc.setFontStyle("normal");
if (base64Img) {
doc.addImage(base64Img, "PNG", data.settings.margin.left, 10, 30, 10);
}
doc.text(title, data.settings.margin.left + 35, 17);
// footer
var str = `Page ${data.pageCount}`;
if (typeof doc.putTotalPages === "function") {
str = str + " of " + totalPagesExp;
}
doc.setFontSize(10);
doc.text(str, data.settings.margin.left, doc.internal.pageSize.height - 10);
};
doc.autoTable({
didDrawPage: pageContent,
html: `#${tableName}`,
margin: {
top: 30,
bottom: 20,
left: 15,
right: 15
},
styles: {
fontSize: 9
}
});
if (typeof doc.putTotalPages === "function")
doc.putTotalPages(totalPagesExp);
return doc.save(fileName + ".pdf");
}