Convert HTML to PDF in ASP.NET MVC

前端 未结 8 691
陌清茗
陌清茗 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:27

    There are a number of html to pdf converters for .NET available out there. I can recommend ExpertPdf (www.html-to-pdf.net).

    Code looks something like this:

    PdfConverter pdfConverter = new PdfConverter();
    
    pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
    byte[] downloadBytes = pdfConverter.GetPdfFromUrlBytes(url);
    

    There is an online demo here: http://www.html-to-pdf.net/free-online-pdf-converter.aspx

提交回复
热议问题