I am using Rotativa (version 1.6.3) to generate pdf from my view. I have a simple partial view(_OverallResultPrintVersion.cshtml):
@Styles.Render("~/bundles/css")
<img src="@Url.Action("DrawChart", "Vote", new {area = "Award"})"/>
In my action when returning Rotativa PartialViewAsPdf, it opens an empty pdf page and the "DrawChart" action won't be called as expected. Here is how I implemented My actions in Vote controller:
public ActionResult OverallResultPdf()
{
return new Rotativa.PartialViewAsPdf(
@"~\Areas\Award\Views\Shared\Widget\_OverallResultPrintVersion.cshtml");
}
public ActionResult DrawChart()
{
var model = getModel();
return PartialView("Widget/_VotesColumnChart", model);
}
When replacing the image source in partial view to an Url, it shows the image but this is not what I'm trying to achieve. Any idea why Rotativa PartialViewAsPdf cannot call my action from partial view?
PS: there is no authorization restriction for these actions so I don't need to initiate FormsAuthenticationCookieName property when creating PartialViewAsPdf.
here is a workaround to resolve the issue. It costs adding a new Action! (OverallResultPrintVersion) and in OverallResultPdf action, instead of returning PartialViewAsPdf, an ActionAsPdf needs to be returned.
and DrawChart() action remains untouched.