本文介绍了如何转换html< div>到pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div id="content">
<h3>Hello</h3>
<table id = "tblHeader" >
<tbody>
<tr>
<td width="10%">name</td>
<td width="15%">id</td>
<td width="27%">Patient Name </td>
<td width="8%">Age</td>
</tr>
</tbody>
</table>
</div>
<button id="cmd">generate PDF</button>
此表我需要转换为pdf.
This table I need to convert to pdf.
我尝试了jspdf和下面提到的功能.
I tried with jspdf and the function noted below.
$(function () {
$('#cmd').click(function () {
var pdf = new jsPDF('p', 'pt', 'letter'),
source = $('#tblHeader')[0],
margins = {
top: 40,
bottom: 40,
left: 40,
right: 40,
width: 522
};
pdf.fromHTML(
source,
margins.left,
margins.top,
{
'width': margins.width
},
function (dispose) {
pdf.save('Test.pdf');
},
margins
);
});
});
它生成了以列数据为行的pdf文件.请帮助我.
And it generated pdf with column data as rows.Please help me.
推荐答案
包括以下脚本文件
<script src="/Scripts/plugin/jsPdf/jspdf.debug.js"></script>
这篇关于如何转换html< div>到pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!