Create RazorPDF for a list of partial views

628 Views Asked by At

I want to make a report in pdf form in asp.net mvc application and at the moment i am showing result as partial views, i.e., my main page is Report and is calling like

public ActionResult Report(int id)
{
    ViewBag.Id =id;
   return View();
} 

And inside Report.cshtml i am calling 5 partial views to render 5 different sections of report like this

<div class="row">
@Html.Action("Report1", "Screening", new { Id = @ViewBag.Id })
</div>
<div class="row">
@Html.Action("Report2", "Screening", new { Id = @ViewBag.Id })
</div>
<div class="row">
@Html.Action("Report3", "Screening", new { Id = @ViewBag.Id })
 </div>
<div class="row">
@Html.Action("Report4", "Screening", new { Id = @ViewBag.Id })
</div>

Now i want to make Report as a pdf and is any way to call Partial view directly from RazorPDF view?

1

There are 1 best solutions below

1
On

Have you tried this?

public ActionResult Report(int id)
{
    ViewBag.Id =id;
    var model=new YourViewModel()
    return new RazorPDF.PdfResult(model, "Report");
}