As in the topic, I want to know if there is a possibility of adding a header/footer on each page?
First, basic question: How can I add footer and header in pdf?
I try by passing below code, but didn't work
{
header:
{
text : "valueOfHeader"
},
footer:
{
text: "valueOfFooter"
}
}
Second question: how can i insert page numbers in footer?
Your sample is working fine, just remember to define content as well as it's mandatory.
Alternatively header and footer can be set to a function taking two arguments (currentPage, pageCount)
For a simple case the following piece of code should be enough:
footer: function(page, pages){ return page + ' of ' + pages; },
Remember the function can return any valid node (if a simple text is not enough), so a more complex example could look like this:
footer: function(page, pages) {
return {
columns: [
'Left part of footer',
{
alignment: 'right',
text: [
{ text: page.toString(), italics: true },
' of ',
{ text: pages.toString(), italics: true }
]
}
],
margin: [10, 0]
};
},
Thank's a lot, now it works well :+1:
dynamic footer footer: function(page, pages){ return page + ' of ' + pages; } is not working in webworker
How can we add line seperator in footer in datatable
Most helpful comment
Your sample is working fine, just remember to define
contentas well as it's mandatory.Alternatively
headerandfootercan be set to a function taking two arguments (currentPage, pageCount)For a simple case the following piece of code should be enough:
Remember the function can return any valid node (if a simple text is not enough), so a more complex example could look like this: