我试图将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页面。