我使用html,javascript和lib html2pdf
如何根据班级大小制作pdf文件(html2pdf)
function generatePDF(){ var element = document.getElementById('purchase-paper'); var opt = { margin: 1, filename: 'test.pdf', image: {type:'jpeg',quality:0.98}, jsPDF: {unit:'in',format:'letter',orientation:'portrait'} }; html2pdf().set(opt).from(element).save(); console.log("Test")};
我只想导出 pdf 1 页。
P粉4035496162024-03-31 00:51:08
试试这个:
function generatePDF(){ var element = document.getElementById('purchase-paper'); var opt = { margin: 1, filename: 'test.pdf', image: {type:'jpeg',quality:0.98}, jsPDF: {unit:'in',format:'letter',orientation:'portrait'}, pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) { if (currentNode.id === 'purchase-paper') { return true; } return false; } }; html2pdf().set(opt).from(element).save(); }