I have two controllers, 1 is an api controller, the other is a view controller, what I am trying to do is generate the PDF from the api controller from a view in the view controller...is this possible and how would I do it?
API Controller - This is where I want to generate the PDF
public byte[] getReportsPDF(string community, string procedure)
{
byte[] pdfBytes = new byte[] { };
System.Web.Mvc.ControllerContext context = new System.Web.Mvc.ControllerContext();
if(procedure == "GetProductionTasks")
{
var actionPDF = new Rotativa.ActionAsPdf("RedBluePDF", new { community = community, procedure = procedure })
{
PageSize = Size.A4,
PageOrientation = Rotativa.Options.Orientation.Landscape,
PageMargins = { Left = 1, Right = 1 }
};
pdfBytes = actionPDF.BuildFile(context);
}
return pdfBytes;
}
View Controller - This is the view I want to generate.
public ActionResult RedBluePDF(string community, string procedure)
{
return View();
}