Colspan 和 Rowspan 使用 JSPDF AutoTable 示例



我是jsPDF的新手,我正在使用jsPDF AutoTable (https://github.com/simonbengtsson/jsPDF-AutoTable(。 我的表中有多个带有子行的带有行跨度和科尔斯潘的表标题。当我使用自动表作为">False"运行JSPDF时,它会在A4上打印完整的表格,但它的紧凑和一半的页面不符合预期。它应该完全打印在A4页面上,宽度为表格,并在多页上打印,标题为日期,页脚为页码。

这是该问题的 JSFiddle。

这是我尝试过的:

//script to download as PDF 
$('#reportpdf').click(function(){
var children = $('#report tr.child').length;
var visibleChildren = $('#report tr.child:visible').length;
$('#report tr.child').show();
var divToPrint=document.getElementById("report");   
$('#report').tableExport({type:'pdf',
fileName: 'Org_Status_Report',
jspdf: {orientation: 'p',
format: 'a4',
margins: {left:20, top:10},
autotable: false}
});
$('#report tr.child').hide();
});

这是我得到的输出:

输出 A4 第一页 上半部分

输出 A4 页-下半页

当我使用AutoTable时,打印的表格没有表格标题,即缺少第一个两个标题。我不知道我的代码中的问题在哪里。尝试了演示和代码中提到的每个示例

以下是使用自动表的代码:

$('#reportpdf').click(function(){
var children = $('#report tr.child').length;
var visibleChildren = $('#report tr.child:visible').length;
$('#report tr.child').show();
var divToPrint=document.getElementById("report");
$('#report').tableExport({type:'pdf',
fileName: 'Org_Status_Report',
//ignoreColumn: [4],
jspdf: {orientation: 'p',
format: 'a4',
margins: {left:20, top:20, botton:20, right:20},
autotable: {
styles: {cellPadding: 2,
fillColor: 'inherit',
textColor: 'inherit',
fontStyle: 'normal',
overflow: 'ellipsize',
halign: 'inherit',
valign: 'middle'},
headerStyles: {
halign: 'inherit',
valign: 'middle'},
alternateRowStyles: {fillColor: 245}
}
}
});
$('#report tr.child').hide();
});

这是我使用自动表时得到的输出:

使用自动表输出为完整的 A4 页面

有专家可以帮忙吗?

我用JSPDF来填写PDF表单。我有一个想法,可能可行,可能不行。

将表单打印为 PDF/然后将其转换为 base 64 图像,并将代码手动粘贴到 JS 中。然后使用 X,Y 轴将数据放置在 Base 64 图像上的所需位置。这可能很痛苦,但经过一些调整后会起作用。

最新更新