简体   繁体   English

创建RazorPDF以获得部分视图列表

[英]Create RazorPDF for a list of partial views

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, ie, my main page is Report and is calling like 我想在asp.net mvc应用程序中以pdf格式生成报告,此刻我将结果显示为局部视图,即我的主页是Report,并且像

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 在Report.cshtml中,我要调用5个局部视图来呈现报告的5个不同部分,如下所示

<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? 现在我想将报告制作为pdf,有什么方法可以直接从RazorPDF视图中调用部分视图吗?

Have you tried this? 你有尝试过吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM