Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
In this tutorial, we explore converting ASPX pages to PDF documents using the IronPDF library in an ASP.NET WebForms application. The process begins by setting up a new project in Visual Studio, filtering project types for ASP.NET WebApplication .NET Framework, and selecting Web Forms. After creating the project, we install IronPDF via NuGet packages, accepting the license agreement. Accessing IronPDF's namespace allows us to call the 'render this page as PDF' function, specifying that the file should be downloaded.
Running the application prompts a save dialog in the browser, rendering the ASPX page as a PDF document. We further customize the output by adding a simple footer, using PDF print options to set text alignment, font family, and size. The tutorial concludes with information on licensing and trial options, inviting users to explore more content on the Iron Software YouTube channel and website.
Below is an example code snippet demonstrating how to convert an ASPX page to a PDF using IronPDF:
using IronPdf;
using System;
using System.Web.UI;
namespace YourNamespace
{
public partial class YourPage : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Create a new instance of the HtmlToPdf class from IronPDF
var renderer = new HtmlToPdf();
// Render the current page to a PDF document
// The RenderUrlAsPdf function converts the specified URL to a PDF
var pdfDocument = renderer.RenderUrlAsPdf(Request.Url.AbsoluteUri);
// Customize the PDF by adding a footer with desired text and styling
pdfDocument.Footer = new SimpleHeaderFooter()
{
CenterText = "Page footer text",
DrawDividerLine = true,
FontSize = 10
};
// Specify that the PDF should be sent to the client as a download
pdfDocument.SaveAs(Response, "YourPage.pdf");
}
}
}
using IronPdf;
using System;
using System.Web.UI;
namespace YourNamespace
{
public partial class YourPage : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Create a new instance of the HtmlToPdf class from IronPDF
var renderer = new HtmlToPdf();
// Render the current page to a PDF document
// The RenderUrlAsPdf function converts the specified URL to a PDF
var pdfDocument = renderer.RenderUrlAsPdf(Request.Url.AbsoluteUri);
// Customize the PDF by adding a footer with desired text and styling
pdfDocument.Footer = new SimpleHeaderFooter()
{
CenterText = "Page footer text",
DrawDividerLine = true,
FontSize = 10
};
// Specify that the PDF should be sent to the client as a download
pdfDocument.SaveAs(Response, "YourPage.pdf");
}
}
}
Imports IronPdf
Imports System
Imports System.Web.UI
Namespace YourNamespace
Partial Public Class YourPage
Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Create a new instance of the HtmlToPdf class from IronPDF
Dim renderer = New HtmlToPdf()
' Render the current page to a PDF document
' The RenderUrlAsPdf function converts the specified URL to a PDF
Dim pdfDocument = renderer.RenderUrlAsPdf(Request.Url.AbsoluteUri)
' Customize the PDF by adding a footer with desired text and styling
pdfDocument.Footer = New SimpleHeaderFooter() With {
.CenterText = "Page footer text",
.DrawDividerLine = True,
.FontSize = 10
}
' Specify that the PDF should be sent to the client as a download
pdfDocument.SaveAs(Response, "YourPage.pdf")
End Sub
End Class
End Namespace
Further Reading: ASPX Pages to PDF in ASP.NET
HtmlToPdf
class provided by IronPDF to render the current ASPX page URL into a PDF format. The pdfDocument.Footer
property allows adding simple styled footer text. The SaveAs
method on the PDF document sends the file to the client for download.