Skip to footer content
USING IRONPDF

PDF Export for ASP.NET Web Forms

Plenty of organizations still run ASP.NET Web Forms behind banking portals, accounting systems, and internal dashboards. The apps are stable, but they rarely offer a clean way to hand a user a downloadable document. Adding PDF export gets framed as a reason to re-platform onto MVC or Blazor, an expensive move for software that otherwise runs fine. IronPDF takes the cheaper route: it turns the ASPX page a user is already viewing into a PDF with one line of code.

Where the Gap Shows Up

A Web Forms page usually renders its invoice, statement, or report as styled HTML already. Staff and customers then want that same view as a portable file they can save, email, or print. A separate PDF template means a second layout that drifts from the first. The browser print dialog yields different results on every machine. What teams need is a server-side PDF that mirrors the page on screen.

Rendering the Page in Place

IronPDF converts the live ASPX page from inside the Page_Load event. The AspxToPdf.RenderThisPageAsPdf method reuses the page already built for the web view, so styling, links, and form fields carry over.

using IronPdf;

public partial class Invoice : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Invoice.pdf");
    }
}
using IronPdf;

public partial class Invoice : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Invoice.pdf");
    }
}
Imports IronPdf

Public Partial Class Invoice
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs)
        AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Invoice.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

FileBehavior.Attachment triggers a download with a chosen filename. FileBehavior.InBrowser displays the document inline instead.

Controlling the Output

Rendering options cover the details that make output fit for distribution: headers, footers, page numbering, and a print stylesheet that strips screen-only navigation.

var options = new ChromePdfRenderOptions
{
    CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print,
    TextFooter = new TextHeaderFooter
    {
        LeftText = "{date} - {time}",
        RightText = "Page {page} of {total-pages}"
    }
};
AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", options);
var options = new ChromePdfRenderOptions
{
    CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print,
    TextFooter = new TextHeaderFooter
    {
        LeftText = "{date} - {time}",
        RightText = "Page {page} of {total-pages}"
    }
};
AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", options);
Imports IronPdf.Rendering

Dim options As New ChromePdfRenderOptions With {
    .CssMediaType = PdfCssMediaType.Print,
    .TextFooter = New TextHeaderFooter With {
        .LeftText = "{date} - {time}",
        .RightText = "Page {page} of {total-pages}"
    }
}
AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", options)
$vbLabelText   $csharpLabel

Settings That Decide a Clean Conversion

A handful of choices determine whether conversion holds up under load:

  • Dynamic content: Pages using Ajax or client-side charts need EnableJavaScript along with a WaitFor rule so rendering captures the finished page. See the WaitFor guide.
  • Print styling: Setting CssMediaType to Print applies a dedicated stylesheet, which keeps buttons and menus out of the document.
  • Throughput: Chromium rendering is resource intensive, so async processing keeps high-traffic endpoints responsive.

One line, no rewrite

That single call inside an existing page gives a Web Forms application invoice downloads, printable statements, and exportable reports, no migration required. Full method reference and configuration options live in the ASPX to PDF guide.

Frequently Asked Questions

Can I add PDF export to ASP.NET Web Forms without migrating to MVC or Blazor?

Yes. IronPDF's AspxToPdf.RenderThisPageAsPdf method converts the live ASPX page to PDF from inside the Page_Load event, reusing the existing page layout without any framework migration.

How does IronPDF handle dynamic content like Ajax charts in Web Forms?

Enable EnableJavaScript in the rendering options and add a WaitFor rule so IronPDF waits until JavaScript has finished executing before capturing the page.

What is the difference between FileBehavior.Attachment and FileBehavior.InBrowser?

FileBehavior.Attachment sends the PDF as a file download with a chosen filename. FileBehavior.InBrowser displays the PDF inline in the browser tab instead.

How do I add headers, footers, and page numbers to an ASPX PDF export?

Use ChromePdfRenderOptions with a TextFooter (or TextHeader) that references the {page} and {total-pages} placeholders. Set CssMediaType to Print to apply your print stylesheet.

Does IronPDF work with ASP.NET Web Forms on the .NET Framework?

Yes. IronPDF supports .NET Framework 4.6.2 and later, as well as .NET Core, .NET 5, and all modern .NET versions. It works in Web Forms applications targeting any of these runtimes.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me