Im trying to print the current page numbers using this: https://github.com/MrRio/jsPDF/pull/260
But jsPDF renders a huge amount of blank pages and crashes :(
Without the footer, every thing works fine and I get a nice PDF with 27 pages, but without footers ofcause
Console errors:

my footer is:
<footer>
<div style='text-align:center;'>Page <span class="pageCounter"></span>/<span class="totalPages"></span></div>
</footer>
and heres my Jquery part:
var doc = new jsPDF();
var margins = {
top: 10,
left: 10,
right: 10,
bottom: 20,
width: 265
};
doc.setProperties({
title: 'Title',
subject: 'This is the subject',
author: 'Author Name',
keywords: 'generated, javascript, web 2.0, ajax',
creator: 'Creator Name'
});
length = doc.internal.getNumberOfPages()
doc.fromHTML(response, margins.left, margins.top,{
'width': margins.width // max width of content on PDF
},
function(){
doc.save('noter.pdf');
}, margins);
You can use this code :

var doc = jsPDF();
doc.addPage();
doc.addPage();
doc.addPage();
doc.addPage();
var pageCount = doc.internal.getNumberOfPages(); //Total Page Number
for(i = 0; i < pageCount; i++) {
doc.setPage(i);
let pageCurrent = doc.internal.getCurrentPageInfo().pageNumber; //Current Page
doc.setFontSize(12);
doc.text('page: ' + pageCurrent + '/' + pageCount, 10, doc.internal.pageSize.height - 10);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With