I am using rotativa to generate PDF.I want to generate multiple PDF based on the number of records in the list below code generate only one pdf.
public ActionResult PreviewPDF(string month,string year)
{
string basePath = ConfigurationManager.AppSettings["PDFPath"];
string fullPath = string.Empty;
string message = CreatePath(basePath, month, year, out fullPath);
if(message.Trim()=="")
{
List<FundMaster> lstFundMaster = commonRepo.GetFundMaster();
foreach(FundMaster fund in lstFundMaster)
{
return RedirectToAction("PDFFactSheetData", "FactSheet", new { fundCode = fund.FundCode, filePath = fullPath });
}
}
return Json(message, JsonRequestBehavior.AllowGet);
}
above action will be called when i click on Preview PDF button where in based on the numbers of records in lstFundMaster List i want to generate a PDFs.Below action is responsible to generate the PDF
public ActionResult PDFFactSheetData(string fundCode="BAL",string filePath="")
{
FactSheet factSheetData = new FactSheet();
factSheetData = factsheetRepo.GetFactSheetData(fundCode);
FundInvestmentStyle investmentStyle = factSheetData.InvestmentStyle;
string pdfFileName = fundCode + ".pdf";
string fullFilePath = Path.Combine(filePath, pdfFileName);
return new ViewAsPdf(templateName, factSheetData) { FileName = pdfFileName, PageSize = Rotativa.Options.Size.A4, SaveOnServerPath = fullFilePath };
}