Jspdf-autotable: Footer table on every page with dynamic page count?

Created on 17 Jun 2020  路  2Comments  路  Source: simonbengtsson/jsPDF-AutoTable

I used autoTable() to draw my footer table with 3 cells, an image, texts, etc. (didParseCell, didDrawCell are used)
But now my dynamic content rolls over to multiple pages, and I'd like to draw the footer table on every page.

I saw the footer example in the example.js, but that only draws simple text in didDrawPage.
How could I draw my footer table on every page?

Thanks in advance!

question stale

Most helpful comment

I guess you just have to draw what you want like in the footer exemple

 for (let i = 0; i < pageCount; i++) { 

       this.doc.setPage(i); // set each page one by one in the loop
// draw what you want where you want
       this.doc.autoTable({
        startY: 260,    
        margin: { top: 260, left: 10, right: 10 },
        head: [['head1', 'head2']],
        body: [
          ['row1 span1', 'row1 span2'],
          ['row2 span1', 'row2 span2'],
        ],

      }, );
        this.doc.line(data.rect.x, data.rect.y, data.rect.w, data.rect.y);  // hline with var etc.
        this.doc.text(190, 285, this.doc.internal.getCurrentPageInfo().pageNumber + '/' + pageCount);
    }

All 2 comments

I guess you just have to draw what you want like in the footer exemple

 for (let i = 0; i < pageCount; i++) { 

       this.doc.setPage(i); // set each page one by one in the loop
// draw what you want where you want
       this.doc.autoTable({
        startY: 260,    
        margin: { top: 260, left: 10, right: 10 },
        head: [['head1', 'head2']],
        body: [
          ['row1 span1', 'row1 span2'],
          ['row2 span1', 'row2 span2'],
        ],

      }, );
        this.doc.line(data.rect.x, data.rect.y, data.rect.w, data.rect.y);  // hline with var etc.
        this.doc.text(190, 285, this.doc.internal.getCurrentPageInfo().pageNumber + '/' + pageCount);
    }

This issue has been automatically closed since the issues in this project are mainly used for bugs and feature requests. Questions are directed to stackoverflow.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sciefylab picture sciefylab  路  6Comments

simonbengtsson picture simonbengtsson  路  5Comments

JoakFlores picture JoakFlores  路  3Comments

ultra2 picture ultra2  路  6Comments

Alorse picture Alorse  路  4Comments