答案 0 :(得分:1)
这样做:
pdf.addHTML(document.getElementById('exportthis'), 5, 10, {
pagesplit: true,
margin: margins
},
function(dispose) {
var pageCount = pdf.internal.getNumberOfPages();
for (i = 0; i < pageCount; i++) {
pdf.setPage(i);
pdf.text(195, 450, pdf.internal.getCurrentPageInfo().pageNumber + "/" + pageCount + "\n");
}
pdf.save("Report.pdf");
});
答案 1 :(得分:1)
JSPDF允许使用margin和useFor功能。您可以如下设置边距属性:
const pdf = new jspdf('p', 'pt', 'a4'); // For A4 Sheet layout
pdf.addHTML(document.getElementById('print-section'), 25, 50, {
retina: true,
pagesplit: true,
margin: {
top: 50,
right: 25,
bottom: 50,
left: 25,
useFor: 'page' // This property is mandatory to keep the margin to supsequent pages
}
}, function() {
pdf.save('test.pdf');
});
请参见以下输出:
答案 2 :(得分:0)
我通过更改addhtml.js文件解决了此问题
https://github.com/MrRio/jsPDF/pull/1450/files 及其对我的工作