Convert from Html To Pdf in ASP.NET MVC with C# and VB.NET

 

ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards.

The core of a web page is a file written in Hypertext Markup Language (HTML). Typically, the HTML file includes associations with other files that either appear on the web page or govern how it looks or works. When you convert a web page to PDF, the HTML file and all associated files - such as JPEG images, cascading style sheets, text files, image maps and forms - are included in the conversion process. The resulting PDF behaves much like the original web page.

ExpertPdf HTML to PDF Converter can be used to turn web pages into PDF documents in ASP.NET MVC applications. The generated PDF documents will look exactly like the web pages that you convert.


ASP.NET MVC C# Controller Code Sample

[HttpPost]
public ActionResult Convert(FormCollection collection)
{
    PdfConverter pdfConverter = new PdfConverter();
    string url = collection["TxtUrl"];
    byte[] pdf = pdfConverter.GetPdfBytesFromUrl(url);

    FileResult fileResult = new FileContentResult(pdf, "application/pdf");
    fileResult.FileDownloadName = "RenderedPage.pdf";

    return fileResult;
}


ASP.NET MVC VB.NET Controller Code Sample

<HttpPost()>
Function Convert(collection As FormCollection) As ActionResult
    Dim pdfConverter As New PdfConverter()
    Dim url As String = collection("TxtUrl")
    Dim pdf As Byte() = pdfConverter.GetPdfBytesFromUrl(url)

    Dim fileResult As FileResult = New FileContentResult(pdf, "application/pdf")
    fileResult.FileDownloadName = "RenderedPage.pdf"

    Return fileResult
End Function




Latest News

May 27th, 2024

ExpertPdf HtmlToPdf Converter v19.0.0 was released.

read more
Mar 30th, 2023

ExpertPdf Pdf To Image Converter v8.0.0 was released.

read more

Pdf Library for .NET

ExpertPDF Html To Pdf Converter

Html to Pdf asp.net

"HTML to PDF is a quality component that is clearly valuable to any Web developer in need of an easy and flexible way to generate PDF files."

Steve C. Orr - MCSD, Microsoft MVP in ASP.NET

more testimonials
customers list

With ExpertPdf you can convert html to pdf in .NET.

Professional aspx to pdf converter, ExpertPdf works with Microsoft Azure if used in a virtual machine or a cloud service.

Copyright 2024. Outside Software Inc.