仅将生成pdf限制为一页吗? html2pdf库

问题描述 投票:0回答:1

我试图将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();
}
javascript jquery html pdf html2pdf
1个回答
0
投票

请尝试为“内容证明”组件设置固定高度。但是,如果您要打印的内容更多,这将限制库生成更多的pdf页面。

© www.soinside.com 2019 - 2024. All rights reserved.