我正在AngularJS中使用HTML2Canvas和JsPDF将多个表转换为横向PDF。我尝试过设置样式,指定宽度,设置固定值,增加内容大小等。不幸的是,表格的宽度永远不会超过特定点(大约页面的3/4)。几乎就像有一个设置的边距/限制。我最新的HTML代码是:
<table class="table1" style="width:2000; font-size: 8px;">
<tr>
<th>Column A</th>
<th>Column B</th>
<th>Column C</th>
</tr>
<tr>
<td>Row 1</td>
<td>Row 2</td>
<td>Row 3</td>
</tr>
</table>
使用JsPDF和HTML2Canvas的AngularJs代码为:
$scope.savePdfSample = function(value) {
html2canvas(document.body,{
onrendered:function(canvas){
var doc = new jsPDF('l', 'pt', 'letter'),
source = $("#template_invoice")[0], //not sure what this does if anyone knows!
margins = {
top: 40,
bottom: 40,
left: 40,
right:40,
width: 2000,
};
doc.fromHTML(
$("#pdfReport").html(),
margins.left,
margins.top,
{
'width': margins.width,
},
function(dispose) {
doc.save('mypdf.pdf');
},
margins
);
}
});
};
谢谢!