Generate PDF based on HTML code (iTextSharp, PDFSharp?)

前端 未结 10 2098
南笙
南笙 2020-12-08 08:15

Does the library PDFSharp can - like iTextSharp - generate PDF files *take into account HTML formatting *? (bold (strong), spacing

10条回答
  •  余生分开走
    2020-12-08 08:50

    Have you guys heard of this. I might be answering very late but I thought it helps. It is very simple and works well.

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

    Edit: I came here with the question of converting HTML code to PDF using 'PDFSharp' and found out that 'PDFSharp' cannot do it then I found out about NReco and it worked for me so I felt it might help someone just like me.

提交回复
热议问题