Convert HTML to PDF in .NET

后端 未结 30 1868
不知归路
不知归路 2020-11-22 00:28

I want to generate a PDF by passing HTML contents to a function. I have made use of iTextSharp for this but it does not perform well when it encounters tables and the layout

30条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 00:41

    I recently performed a PoC regarding HTML to PDF conversion and wanted to share my results.

    My favorite by far is OpenHtmlToPdf

    Advantages of this tool:

    • Very good HTML compatibility (e.g. it was the only tool in my example that correctly repeated table headers when a table spanned multiple pages)
    • Fluent API
    • Free and OpenSource (Creative Commons Attribution 3.0 license)
    • Available via NuGet

    Other tools tested:

    • ExpertPDF (http://www.html-to-pdf.net/)
    • IronPDF (http://ironpdf.com/)
    • iTextSharp (https://sourceforge.net/projects/itextsharp/)
    • NReco PDF Creator for .NET (http://www.nrecosite.com/pdf_generator_net.aspx)
    • HTML renderer for PDF Sharp (https://www.nuget.org/packages/HtmlRenderer.PdfSharp/)
    • SelectPDF community edition (http://selectpdf.com/community-edition/)

提交回复
热议问题