【发布时间】:2015-12-18 07:27:21
【问题描述】:
我想复制/保存/打印多个 div 及其内容并将其保存在 pdf 文件中,使用 jspdf 时遇到对齐和复制图像的问题。
有什么建议可以打印 div 并将其保存为 pdf 文件吗?
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).html());
//alert($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title>my div</title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
// mywindow.focus(); // necessary for IE >= 10
mywindow.print();
//mywindow.close();
return true;
}
</script>
以上代码将详细信息保存在 xps 扩展名中,在此之前我想将详细信息捕获到 pdf 文件中?它需要像一般的 pdf 下载一样
请给点建议,如何将可打印的数据保存为pdf?
【问题讨论】:
-
请向我们展示您的尝试。因此,我们可以根据您的发现提出建议。
-
-
嗨StijinvanGaal,是否有可能将元素详细信息打印到pdf文件中?
标签: javascript jquery