我正在使用rotativa生成PDF。我想根据下面列表中的记录数生成多个PDF代码只生成一个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);
}
当我点击预览PDF按钮时,将调用上面的操作,其中根据lstFundMaster列表中我想生成PDF的记录数量.Below动作负责生成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 };
}