[英]HTML Save as PDF 2 Pages
我有一个按钮来打印我的HTML作为PDF。 问题是我需要它打印两页。 不同的浏览器搞砸了,没有正确打印第二页。 我如何使用我的代码特定第2页..
function printPageArea(areaID){ var printContent = document.getElementById(areaID); var WinPrint = window.open('', '', 'width=830,height=792'); WinPrint.document.write(printContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); }
<a href="javascript:void(0);" style="position: relative;left: 0;top: 50px;" onClick="printPageArea('printableArea')"><button class="custom" style="width:auto!important;">Download PDF</button></a> <div class="content-wrap-consent" id="printableArea"> <div class="page-one"> Page One </div> <div class="page-two"> Page two </div> </div>
您可以使用page-break-before
或page-break-after
分别在元素之前或之后插入分页符。
@media print {
.page-two {
page-break-before: always;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.