Convert HTML to PDF in .NET

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

    You can also check Spire, it allow you to create HTML to PDF with this simple piece of code

     string htmlCode = "

    This is a p tag

    "; //use single thread to generate the pdf from above html code Thread thread = new Thread(() => { pdf.LoadFromHTML(htmlCode, false, setting, htmlLayoutFormat); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); // Save the file to PDF and preview it. pdf.SaveToFile("output.pdf"); System.Diagnostics.Process.Start("output.pdf");

    Detailed article : How to convert HTML to PDF in asp.net C#

提交回复
热议问题