Javascript 是否将生成pdf限制为仅一页?html2pdf库
我想把pdf限制在一页以内,有没有办法限制它 代码如下:Javascript 是否将生成pdf限制为仅一页?html2pdf库,javascript,jquery,html,pdf,html2pdf,Javascript,Jquery,Html,Pdf,Html2pdf,我想把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 = {
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页面,以防您有更多内容要打印。请提供一些上下文,只是将错误消息放在问题中没有帮助。还要考虑一下追问。@你有什么评论吗?我似乎无法与这个答案联系起来。