【问题标题】:Can I Convert a Index.cshtml in asp.net MVC to PDF using html2pdf?我可以使用 html2pdf 将 asp.net MVC 中的 Index.cshtml 转换为 PDF 吗?
【发布时间】:2021-08-21 11:40:36
【问题描述】:

我在使用 html2pdf 库和 jquery 将 asp.net MVC 中的视图转换为 PDF 时遇到问题, 所以请有人帮忙吗?

提前致谢。

【问题讨论】:

  • 请尽可能详细地写出错误消息以及您可能遇到问题的源代码中最相关的部分。

标签: asp.net-mvc pdf model-view-controller converters html2pdf


【解决方案1】:

我用的是Rotativa,感觉不错 Rotativa 是一个开源软件包,它使用 Chrome 浏览器使用的 Web 工具包引擎来呈现 HTML。该框架支持大多数 HTML 标记和样式。 它包含许多可用于转换为 pdf 的类,例如:

  • ActionAsPdf
  • PartialViewAsPdf
  • UrlAsPdf
  • 查看为 PDF 例如
    <div style="text-align:right">@Html.ActionLink("Print Employee", 
    "PrintEmployee", new { id=Model.ID })</div>  

    public ActionResult PrintEmployee(int id)  
    {  
      var report = new Rotativa.ActionAsPdf("Employee", new { id=id });  
      return report;  
    }  

【讨论】:

    猜你喜欢
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    相关资源
    最近更新 更多