簡體   English   中英

將生成的 pdf 限制為一頁? html2pdf 庫

[英]Limit the generate pdf to one page only? html2pdf library

我試圖將pdf限制為一頁,有沒有辦法限制它?

代碼下方:

function generatePDF() {
  // Choose the element that our invoice is rendered in.
  const element = document.getElementById("content-certificate");
  // Choose the element and save the PDF for our user.
  var opt = {
    filename: 'sample.pdf', 
    image: {type: 'jpg', quality: 0.2}, 
    html2canvas: {dpi: 192, letterRendering: true, useCORS: true}, 
    jsPDF: {unit: 'pt', format: 'letter', orientation: 'portrait'            
  }};
  html2pdf().from(element).set(opt).save();
}

請嘗試為“內容證書”組件設置固定高度。 但是,如果您有更多內容要打印,這將限制庫生成更多 pdf 頁面。

暫無
暫無

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

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