Convert HTML to PDF in ASP.NET MVC

前端 未结 8 681
陌清茗
陌清茗 2021-02-06 07:56

Im working in a project which requires current html page to convert in pdf and that pdf will automatically save on button click on server and its reference will be save in da

8条回答
  •  醉话见心
    2021-02-06 08:20

    I used iDiTect.Converter to convert html to pdf in asp.net mvc https://www.iditect.com/tutorial/html-to-pdf/, however it's not free code in short

    public static Byte[] ConvertToBytes()
    {
    HtmlToPdfConverter converter = new HtmlToPdfConverter();
    
    converter.DefaultStyleSheet = ".para{font-size: 24px; color: #FF0000;}";
    
    string htmlContent = "

    Content with special style.

    Content without style

    "; converter.Load(htmlContent); return converter.SaveAsBytes(); }

提交回复
热议问题