繁体   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