IRONSOFTWAREHOME

Generate PDF Reports in ASP.NET with C# or VB

Curtis Chau
Curtis Chau
Updated: September 5, 2026

IronPDF enables .NET developers to generate PDF reports from HTML, Crystal Reports, XML, and SQL Server data by rendering HTML content as PDF documents. This C# library simplifies report creation in ASP.NET applications with just a few lines of code, preserving all formatting and styling.

Quickstart: Generate PDF Reports with IronPDF

Get started with generating PDF reports using IronPDF in just a few lines of code. This quick guide enables developers to instantly convert HTML content into professional PDF documents, preserving all formatting effortlessly. Follow the example below to see how simple it is to transform your data into a polished PDF report.

  1. 1Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. 2Copy and run this code snippet.

    // Instantiate ChromePdfRenderer for HTML to PDF conversion
    new IronPdf.ChromePdfRenderer().RenderHtmlFileAsPdf("report.html").SaveAs("report.pdf");
    C#
  3. 3Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

Step 1

How Do I Install IronPDF?

IronPDF on NuGet

PM > Install-Package IronPdf

You can also download the IronPDF DLL manually. For advanced installation scenarios, check our comprehensive NuGet packages guide that covers configuration for Azure, AWS, Linux, Mac, and Windows platforms. If you're working with containerized applications, our Docker integration guide provides detailed setup instructions.


How to Tutorial

What Is the Methodology for Creating a PDF Report?

First generate the report as an HTML document, then render the HTML as a PDF using IronPDF. This tutorial shows you the steps to create a PDF report in ASP.NET C#. IronPDF's Chrome rendering engine ensures pixel-perfect conversion while supporting modern HTML5, CSS3, and JavaScript.

using IronPdf;

ChromePdfRenderer renderer = new ChromePdfRenderer();

renderer.RenderHtmlFileAsPdf("report.html").SaveAs("report.pdf");

For more complex reporting needs, explore our comprehensive PDF creation tutorial which covers watermarks, compression, backgrounds, headers, footers, forms, and password protection.

How Do I Convert Crystal Reports to PDF with .NET?

Export Crystal Reports to HTML using:

File → Export → HTML 4.0

The resulting report can then be exported as a PDF using the above C# example code in the Methodology section. IronPDF provides excellent support for converting HTML files to PDF, maintaining all formatting and styles from your Crystal Reports output.

Here's an example:

using IronPdf;
using IronSoftware.Drawing;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Add a header to very page easily
renderer.RenderingOptions.FirstPageNumber = 1;
renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
renderer.RenderingOptions.TextHeader.CenterText = "{url}";
renderer.RenderingOptions.TextHeader.Font = FontTypes.Arial;
renderer.RenderingOptions.TextHeader.FontSize = 12;

// Add a footer too
renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
renderer.RenderingOptions.TextFooter.Font = FontTypes.Arial;
renderer.RenderingOptions.TextFooter.FontSize = 10;
renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";

renderer.RenderHtmlFileAsPdf(@"c:\my\exported\report.html").SaveAs("report.pdf");

For advanced header and footer customization, including HTML-based headers, visit our headers and footers guide.

How Can I Convert Crystal Reports to PDF Programmatically?

If you wish to work programmatically to create a PDF from a Crystal Reports (RPT) file, it's also possible and gives you much more control. This approach integrates seamlessly with IronPDF's rendering options for complete customization.

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.IO;
using IronPdf;

public static void ExportRptToPdf(string rptPath, string pdfOutputPath)
{
    // Load the Crystal Report
    ReportDocument rpt = new ReportDocument();
    rpt.Load(rptPath);

    // Configure export options for HTML output
    DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions()
    {
        DiskFileName = @"c:\tmp\html\b.html" // Temporary HTML file
    };

    ExportOptions exportOpts = ExportOptions.CreateExportOptions();
    exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
    exportOpts.ExportFormatType = ExportFormatType.HTML40; // Export as HTML 4.0
    exportOpts.ExportDestinationOptions = diskOpts;

    // Export report to HTML
    rpt.Export();

    // Convert HTML to PDF using IronPDF
    var Renderer = new ChromePdfRenderer();
    // Add dynamic header with URL
    Renderer.RenderingOptions.TextHeader.CenterText = "{url}";
    // Add footer with timestamp and page numbers
    Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
    Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";

    // Render the HTML file to PDF and save
    Renderer.RenderHtmlFileAsPdf(diskOpts.DiskFileName).SaveAs(pdfOutputPath);

    Console.WriteLine("Report Written To {0}", Path.GetFullPath(pdfOutputPath));
}
C#

My favorite library of this kind is IronPDF. It allows for fast and efficient manipulation of PDF files. It also has many valuable features, like exporting to PDF/A format and digitally signing PDF documents.

Milan Jovanovic

Microsoft MVP

View case study

IronOCR means we can save $40,000 annually from manual processing, while enhancing productivity and freeing up resources for high-impact tasks. I would highly recommend it.

Brent Matzelle

Chief Technology Officer, OPYN

View case study

The IronSuite play a crucial role in our operations. These are tools that increase efficiencies across the business including creating floor plans and improving inventory management.

David Jones

Lead Software Engineer, Agorus Build

View case study

How Do I Generate PDF Reports from XML?

Exporting report data as XML is still common despite the prevalence of easier-to-code formats such as JSON. IronPDF offers excellent support for XML to PDF conversion, providing multiple approaches to handle XML data.

To style XML reports, parse the XML and generate HTML with the data.

A more elegant solution is to use XSLT to convert XML directly to HTML using the XslCompiledTransform class as documented in the article Using the XslCompiledTransform Class.

The resultant HTML string or file may then be rendered as a PDF using IronPDF:

using System.IO;
using System.Xml;
using System.Xml.Xsl;
using IronPdf;

public static void ConvertXmlToPdf(string xml, string xslt, string pdfOutputPath)
{
    // Initialize XSLT transformation
    XslCompiledTransform transform = new XslCompiledTransform();
    using (XmlReader reader = XmlReader.Create(new StringReader(xslt)))
    {
        transform.Load(reader); // Load XSLT stylesheet
    }
    
    // Transform XML to HTML
    StringWriter results = new StringWriter();
    using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
    {
        transform.Transform(reader, null, results); // Apply transformation
    }

    // Convert the generated HTML to PDF
    ChromePdfRenderer renderer = new ChromePdfRenderer();
    renderer.RenderHtmlAsPdf(results.ToString()).SaveAs(pdfOutputPath);
}

Please visit the Convert XML to PDF in C# and VB.NET article to learn more about advanced XML transformation techniques and best practices.

How Do I Export SQL Server Reports to PDF?

Microsoft's SQL Server and the free SQL Server Express contain reporting tools. Exporting SSRS reports to a PDF in ASP.NET can be a useful use of IronPDF. For complex data visualization needs, IronPDF supports rendering JavaScript charts including popular libraries like C3.js, D3.js, and Highcharts.

Tutorial: How to locate and start Reporting Services tools (SSRS)

These reports may be generated as HTML which may then be customized and converted to PDF format using IronPDF. IronPDF's HTML string to PDF conversion feature provides complete control over the final output.

Render to HTML (Report Builder)

For enterprise environments requiring secure data access, IronPDF supports TLS website and system logins to handle authenticated report generation.

How Do I Secure PDF Reports?

To ensure a PDF report has not been modified or tampered with, digitally sign it. This is most easily achieved on a PDF report file after it has been rendered and saved to disk. IronPDF provides comprehensive PDF signing capabilities including support for Hardware Security Modules (HSM).

using IronPdf.Signing;

// Sign our PDF Report using a p12 or pix digital certificate file
new PdfSignature("IronSoftware.pfx", "123456").SignPdfFile("signed.pdf");

If you do not have a digital signature, you can create a new digital signature file using the free Adobe Acrobat Reader on macOS and Windows. For additional security measures, explore our PDF permissions and passwords guide to control document access and editing rights.

How Do I Convert ASPX to PDF with ASP.NET Webforms?

The easiest way to serve HTML content in ASP.NET is to use the IronPdf.AspxToPdf class on the Form_Load event of an ASP.NET WebForms application. This powerful feature allows you to convert entire ASPX pages, including server-side controls and dynamic content, directly to PDF.

using IronPdf;

public static void RenderAspxToPdf()
{
    // Configure PDF rendering options
    var AspxToPdfOptions = new ChromePdfRenderOptions()
    {
        EnableJavaScript = false, // Disable JavaScript for simpler reports
        PrintHtmlBackgrounds = true, // Include background colors and images
        MarginTop = 20, // Set top margin in mm
        MarginBottom = 20, // Set bottom margin in mm
        PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait,
        PaperSize = IronPdf.Rendering.PdfPaperSize.A4
        // ...many more options available
    };

    // Render the HTML page to PDF and prompt download
    AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Report.pdf", AspxToPdfOptions);
}
C#

We hope this article has helped you in learning how to generate a PDF report in ASP.NET C# or VB.NET. You can also take a look through our full ASP.NET ASPX to PDF Tutorial to learn more about advanced scenarios including ASPX page to PDF settings and handling complex layouts.

Frequently Asked Questions

How do I generate a PDF report using C# in ASP.NET?

To generate a PDF report using C# in ASP.NET, you can utilize the IronPDF library. By converting HTML content, Crystal Reports, XML, or SQL Server data into PDFs, IronPDF ensures that all formatting and styling are preserved. Simply render HTML as a PDF through IronPDF's straightforward API.

What is the quickest way to convert HTML to PDF with IronPDF?

The quickest way to convert HTML to PDF with IronPDF is by using the ChromePdfRenderer class. With just a few lines of code, you can load your HTML content and save it as a PDF document, ensuring perfect formatting and presentation.

Can I convert Crystal Reports to PDF in .NET?

Yes, you can convert Crystal Reports to PDF in .NET by exporting the report to HTML first and then using IronPDF to render the HTML into a PDF. This approach maintains the formatting of the original Crystal Report.

How do I install IronPDF for report generation?

IronPDF can be installed through NuGet by searching for the 'IronPdf' package. Alternatively, you can download the DLL manually and follow the comprehensive installation guides for various platforms including Azure, AWS, and more.

Is it possible to secure generated PDF reports?

Yes, it is possible to secure PDF reports by digitally signing them. IronPDF provides capabilities to sign PDF reports, ensuring that they have not been tampered with. You can use digital certificates for additional security.

Can I export SQL Server reports to PDF using IronPDF?

Yes, IronPDF can be used to export SQL Server reports to PDF. By first rendering the reports as HTML, you can then use IronPDF to convert them into high-quality PDFs, suitable for complex data visualization needs.

What are the options for customizing PDF reports in IronPDF?

IronPDF allows you to customize PDF reports extensively, including adding headers, footers, watermarks, and even securing the documents with passwords. The rendering options provide flexibility in style and layout adjustments.

How do I convert an ASPX page to PDF using IronPDF?

IronPDF offers the `AspxToPdf` class to directly convert ASPX pages to PDF in ASP.NET WebForms. This includes server-side controls and dynamic content, allowing you to generate complete PDF versions of ASPX pages effortlessly.

Can XML be converted to PDF with IronPDF?

Yes, XML can be converted to PDF using IronPDF by first transforming XML data into HTML through XSLT, and then converting the HTML to PDF. This process ensures that the layout and data integrity are maintained.

Does IronPDF support digitally signing PDF reports?

Yes, IronPDF supports digitally signing PDF reports to ensure document integrity. You can use P12 or PIX digital certificates to sign PDF files, securing them against unauthorized modifications.

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

Ready to Get Started?

Nuget Downloads 20,990,528Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999