Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have to add header and footer to a pdf document.I am using MVC4 and rendering view to pdf document and downloading by using ITextSharp.Now I am using the below code

public ActionResult DownloadPDF(string shipId)
{
var report = new ActionAsPdf("ExporttoPDF", new { shipId = shipId });
return report;
}

Could any one please help me how to add header and footer while downloading the pdf through code.

What I have tried:

I have rendered the view to a pdf document to show the report,I have to add header and footer for the same report from the code.
Posted
Comments
Richard MacCutchan 25-Sep-17 9:01am    
Where is the iTextSharp code that creates the PDF?
Member 8557048 26-Sep-17 3:51am    
Hi Richard,
I am using Rotativa library
Here is the code below

string footer = "--footer-right \"Date: [date] [time]\" " + "--footer-center \"Page: [page] of [toPage]\" --footer-line --footer-font-size \"9\" --footer-spacing 5 --footer-font-name \"calibri light\"";
return new ViewAsPdf("ExporttoPDF", viewModel) { CustomSwitches = footer };
After this I am getting the exceptions like master page related or
Exit with code 1 due to network error:
like this.

Could you please help me on this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900