Convert HTML to PDF in .NET

后端 未结 30 1818
不知归路
不知归路 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:50

    I highly recommend NReco, seriously. It has the free and paid version, and really worth it. It uses wkhtmtopdf in background, but you just need one assembly. Fantastic.

    Example of use:

    Install via NuGet.

    var htmlContent = String.Format("Hello world: {0}", DateTime.Now);
    var pdfBytes = (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(htmlContent);
    

    Disclaimer: I'm not the developer, just a fan of the project :)

提交回复
热议问题