【发布时间】:2020-10-04 02:34:17
【问题描述】:
我正在尝试弄清楚如何使用 jsPDF .html() 方法调整 HTML 元素的大小。
我尝试使用下面的代码,但 width 选项似乎对输出没有任何改变。
我只是假设width 是.html() 的一个选项,不幸的是,到目前为止,
这种方法没有文档,应该猜到from the code。
另外,在我看来,它应该从html2canvas options 中选择,这就是我尝试使用width 的原因。
不管怎样,代码:
var legend = document.getElementById("my-table");
var pdf = new jsPDF(orientation, undefined, format);
pdf.html(legend, {
width: 200,
callback: function () {
window.open(pdf.output('bloburl'));
}
});
#my-table
<table>
<tr>
<td><img src="image1.jpeg"></td>
</tr>
<tr>
<td><img src="image2.jpeg"></td>
</tr>
...
</table>
【问题讨论】:
标签: javascript html pdf jspdf html2canvas