使用 MVC Razor 中的 iTextSharp 在 MVC 中将 HTML 转换为 PDF [英] Convert HTML to PDF in MVC with iTextSharp in MVC Razor
问题描述
我正在尝试在 MVC Razor 中使用 iTextSharp
将 HTML 转换为 PDF,但是我尝试过的所有方法都没有奏效.有谁知道如何做到这一点?
I am trying to convert HTML to PDF with iTextSharp
in MVC Razor, but everything I have tried has not worked. Does anyone know how to accomplish this?
推荐答案
这里有详细的分步教程
.它说明了如何使用 iTextSharp 将 ASP.NET MVC 视图作为 PDF 文件进行转换.但请记住,iTextSharp 并不是用于将 HTML 转换为 PDF,因此它可能无法很好地处理复杂的 HTML 页面和 CSS 样式.
There's a detailed and step-by-step tutorial
on CodeProject you might follow. It illustrates how you could serve an ASP.NET MVC View as PDF file using iTextSharp for the conversion. Bear in mind though that iTextSharp was not meant for converting HTML to PDF so it might not cope very well with complex HTML pages and CSS styles.
这篇关于使用 MVC Razor 中的 iTextSharp 在 MVC 中将 HTML 转换为 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!