Adding Footer to pdf using jsPDF

Sumeet picture Sumeet · Nov 4, 2015 · Viewed 36k times · Source

I am generating pdf from jsPDF api , I want to add footer to each page with page number .

How to achieve this . It is having option of adding footer from fromHTML plugin , but I am writing without HTML.

var doc = new jsPDF("portrait","px","a4");

Answer

Bas van Stein picture Bas van Stein · Nov 4, 2015

You have to implement it yourself. You can do something like this:

var doc = new jsPDF();
doc.page=1; // use this as a counter.

function footer(){ 
    doc.text(150,285, 'page ' + doc.page); //print number bottom right
    doc.page ++;
};

// and call footer() after each doc.addPage()