-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Is it possible to change header text for each page? #750
Comments
The header can be be populated with any data before creating it. Here is what i do in typescript.
I want to be able to alter the text of the header depending on the data I am using to populate the PDF. This is something else other than changing the page number/page count.— |
@tcsaddul - Are you saying that does not work? I suspect it does not. The only way I have been able to sort-of get something like this to work is to create an array indexed by what I think will be the page number and then use something like Does anyone have a better way to do something like this? |
Yes, I have! I was also facing this problem and solved it with something like this: docDefinition.content.push({
text: aText,
fontSize: 18,
bold: true,
italics: true,
pageHeaderText: yourHeaderText
}); Next, the header function should look something like this: docDefinition.header = function(currentPage){
var rightText = "";
for(var l = 0; l < docDefinition.content.length; l++){
if(docDefinition.content[l].pageHeaderText && currentPage >= docDefinition.content[l].positions[0].pageNumber){
rightText = docDefinition.content[l].pageHeaderText;
}
}
var headerObj = {
columns: [
{
stack: [
{
image: 'Logo',
width: 100
}
],
alignment: 'left',
width: 200
},
{
text: rightText,
color: '#666666',
alignment: 'right',
width: '*',
margin: [0, 12]
}
],
margin: [40, 20]
};
return headerObj;
} |
duplicate: #178 |
I want to be able to alter the text of the header depending on the data I am using to populate the PDF. This is something else other than changing the page number/page count.
The text was updated successfully, but these errors were encountered: