我正在尝试使用jQuery使用以下代码将HTML元素写入PDF:
<div id="testdiv">
<div>An example question goes here and you fill in the box below with your answer</div>
<div><textarea class="Textbox1" cols="50" rows="5">Text area</textarea></div>
</div>
<a href="javascript:genPDF()">Download PDF</a>
<script>
function genPDF() {
var doc = new jsPDF();
doc.fromHTML($("#testdiv").get(0), 0, 0, { width: 500 });
doc.save("Test.pdf");
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.min.js" integrity="sha256-vIL0pZJsOKSz76KKVCyLxzkOT00vXs+Qz4fYRVMoDhw=" crossorigin="anonymous"></script>
所以一切正常,但并不完全符合我的预期。如果查看生成的PDF,是否在每行之后添加一个空白字符?关于如何阻止这种情况的任何想法? pdf image