Home >Backend Development >C++ >What are the Best Alternatives to iTextSharp for Converting HTML to PDF in .NET?
In the environment of .NET environment, the improvement plan of HTML to PDF
When using ITEXTSHARP to process HTML content to generate PDF, the table and layout problem often have a headache. Fortunately, some better alternatives can effectively solve these problems.
<.> 1. htmlrenderer.pdfsharp:
HTMLRENDERER.PDFSHARP is an HTML to PDF solution that is completely from C#management, thread safe and free. The method of use is very simple. Just a simple function can generate PDF:
<.> 2. Rotativa (suitable for the MVC web application):
<code class="language-csharp">public static Byte[] PdfSharpConvert(String html) { Byte[] res = null; using (MemoryStream ms = new MemoryStream()) { var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4); pdf.Save(ms); res = ms.ToArray(); } return res; }</code>
Rotativa is a popular library designed for the MVC Web application. It interacts seamlessly with the underlying WKHTMTOPDF binary file, which renders PDF from HTML. Rotativa allows you to generate PDF directly from Razor view, which is very convenient:
Avoid solutions based on WKHTMLTOPDF
<code class="language-csharp">return ViewAsPdf();</code>
Although WKHTMLTOPDF is a well -known solution, it may also bring some challenges:
Cross -platform compatibility between 32 -bit and 64 -bit systemsThe complexity of the environmental configuration in Azure, Elastic Beanstalk
The above is the detailed content of What are the Best Alternatives to iTextSharp for Converting HTML to PDF in .NET?. For more information, please follow other related articles on the PHP Chinese website!