我举的例子(点击“导出 PDF”即可查看)如下:https://jsfiddle.net/j9vaqpnz/7/
我的表格样式如下:
然后使用库jspdf和autotable将表格导出为 PDF。
在导出过程中,我使用“drawCell”函数,并将所有包含数字的列向右对齐,方法如下:
drawCell: function (cell, data) {
var col = data.column.index;
if(col==3 || col==5 || col==6 || col==7 || col==8 || col==9 || col==10){
cell.styles.halign = 'right';
}
}
问题:在PDF中,我将所有右对齐的列都定位不当,显示如下:
![enter image description here](https://istack.dev59.com/kHJFh.webp)