簡體   English   中英

HTML另存為PDF 2頁

[英]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> 

我想你需要在css中使用@media print

以下是一些鏈接,

使用CSS3 @media查詢創建打印樣式

CSS Printing - @media Rule

您可以使用page-break-beforepage-break-after分別在元素之前或之后插入分頁符。

@media print {
    .page-two {
        page-break-before: always;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM