Reputation: 127
Is there a way to create a table footer in pdfMake? I have a big table that only fits on multiple pages. I want to repeat the table footer on each page.
Upvotes: 6
Views: 12077
Reputation: 830
try this footer
footer: function (currentPage, pageCount) {
return currentPage.toString() + " of " + pageCount;
},
or
footer: {
columns: [
'Report generated on 8/30/2021 6:02:31PM',
{ text: 'Page 1 of 2', alignment: 'right' },
// { text: 'Developed by KRATOS Fitness Software ', alignment: 'left' },
],
},
footer: {
columns: [
'Report generated on 8/30/2021 6:02:31PM',
'Developed by XYZ Fitness Software',
{
alignment: 'right',
text: 'Page 1 of 2'
},
{
alignment: 'right',
text: 'www.xyz.com'
},
],
margin: [60, 10, 60, 10 ]
},
It's work
Upvotes: -1
Reputation: 11
I finally figured out how to do this. (1.) Increase your current "headerRows" count by 1. (2.) Put the footer row between your header row and data rows. (3.) Set marginTop of footer row to a little less than the height of the page. (4.) Set marginBottom of footer row to ((marginTop + height of row) * -1).
This pushes the table footer outside the space of the table into the footer space of the page.
Example:
table: { headerRows: 2, widths: [700], body: [
[{ text: 'My Header' }],
[{ marginTop: 480, marginBottom: -490, text: 'My Footer' }], //480 roughly fits Landscape-Letter
[{ text: 'My Data Row 1' }],
[{ text: 'My Data Row 2' }],
// more data rows
[{ text: 'My Data Row N' }]
]}
Upvotes: 1
Reputation: 1485
Add this to your document:
footer: {
columns: [
'',
{
alignment: 'right',
text: 'Footer text'
}
],
margin: [10, 0]
}
Upvotes: 3
Reputation: 18105
Seems like it is still not implemented: https://github.com/bpampuch/pdfmake/issues/620
Upvotes: 2