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