I wanted to print header data which are dynamic and will come from controller.
So how can I display that dynamic data in header using Rotativa pdf.
My header data include Name, Address, Contact info and other additional information, which are dynamic and generated from controller side.
I have created pdf with static header as below by using html page
string header = Server.MapPath("~/Static/NewFolder/PrintHeader.html");
string footer = Server.MapPath("~/Static/NewFolder/PrintFooter.html");
string customSwitches = string.Format("--header-html \"{0}\" " +
"--header-spacing \"0\" " +
"--footer-html \"{1}\" " +
"--footer-spacing \"10\" " +
"--footer-font-size \"10\" " +
"--header-font-size \"10\" ", header, footer);
return new ViewAsPdf("SchedulePrintPdf", modelData)
{
CustomSwitches = customSwitches,
PageOrientation = Orientation.Portrait,
PageMargins = { Top = 20, Bottom = 22 },
SaveOnServerPath = filePath, FileName = Path.GetFileName(fileName)
};
This is working well with Static header.
Now I need the header text will go from this controller dynamically.