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);
Note: In future this view will be stored in database and will be rendered as VirtualPath
I solved it!
For the
view
I used the absolute paths.
And for theControllerContext
,I passed its object as a parameter from controller.
Also I usedSystem.Web.Mvc
package
Thank you to all!