javascripthtmljspdf

Adding Footer to pdf using jsPDF


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");

Solution

  • 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()