I want to email a PDF sales report to all the agents and this PDF need to be generated dynamically for each agent. I used ItextSharp
for that but that requires too much fiddling with html code. Finally I landed on Rotativa
, it works well but there are almost more then few thousands of agents and I have a separate Business Layer to do this job. How do I make Rotativa to work in business layer?
var pdfResult = new ViewAsPdf("CreateIMDStatmentReport", _IReportManagement.GetIMDStatmentReportByIMDCode(imdCode));
var binary = pdfResult.BuildPdf(this.ControllerContext);
System.Net.Mail.Attachment data = new Attachment(new MemoryStream(binary), MediaTypeNames.Application.Pdf);
- How to get a view in separate Business Layer?
- How do I deal with ControllerContext?
Note: In future this view will be stored in database and will be rendered as VirtualPath