IronPDF How-Tos Generating PDF Reports Generate PDF Reports in ASP.NET with C# or VB Chaknith Bin Updated:June 22, 2025 Generating management or database reports from structured data such as SQL is a common .NET development task. IronPDF can be used as a PDF reader in C# and helps visualize and export SSIS reports to PDF in ASP.NET C#. IronPDF can be used to render snapshots of data as "reports" in PDF file format. It also works as a PDF C# parser. Generate HTML-based PDF reports in one line! new IronPdf.ChromePdfRenderer().RenderHtmlFileAsPdf("report.html").SaveAs("report.pdf"); Install with NuGet PM > Install-Package IronPdf How to Generate C# PDF Reports Download and Install the IronPDF C# PDF Report Library Generate the report as an HTML document and then render the HTML as a PDF Export to HTML using: File -> Export and select HTML 4.0 Style an XML report, the XML may be parsed and then HTML generated with the data Ensure a PDF report has not been modified or tampered with; it may be digitally signed Step 1 1. Install IronPDF Using NuGet: IronPdf on NuGet Install-Package IronPdf You can also download the IronPDF DLL manually. How to Tutorial 2. Methodology for Creating a PDF Report The basic methodology is to first generate the report as an HTML document and then render the HTML as a PDF using IronPDF. This tutorial will show you the steps to create a PDF report in ASP.NET C#. :path=/static-assets/pdf/content-code-examples/how-to/csharp-pdf-reports-render-html-file.cs using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); renderer.RenderHtmlFileAsPdf("report.html").SaveAs("report.pdf"); Imports IronPdf Private renderer As New ChromePdfRenderer() renderer.RenderHtmlFileAsPdf("report.html").SaveAs("report.pdf") $vbLabelText $csharpLabel 3. Crystal Reports to PDF with .NET In the Crystal Reports Application, you may export to HTML using: File -> Export and select HTML 4.0 The resulting report can then be exported as a PDF using the above C# example code in the Methodology section. Here's an example: :path=/static-assets/pdf/content-code-examples/how-to/csharp-pdf-reports-render-header-footer.cs 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"); Imports IronPdf Imports IronSoftware.Drawing Private renderer As 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") $vbLabelText $csharpLabel 3.1 Crystal Reports to PDF Programmatically with C# 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. using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.IO; using IronPdf; public static void ExportRptToPdf(string rptPath, string pdfOutputPath) { ReportDocument rpt = new ReportDocument(); rpt.Load(rptPath); // Set export options DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions() { DiskFileName = @"c:\tmp\html\b.html" }; ExportOptions exportOpts = ExportOptions.CreateExportOptions(); exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; exportOpts.ExportFormatType = ExportFormatType.HTML40; exportOpts.ExportDestinationOptions = diskOpts; // Export report to HTML rpt.Export(); // Convert HTML to PDF var Renderer = new ChromePdfRenderer(); Renderer.RenderingOptions.TextHeader.CenterText = "{url}"; Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"; Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"; Renderer.RenderFileAsPdf(diskOpts.DiskFileName).SaveAs(pdfOutputPath); Console.WriteLine("Report Written To {0}", Path.GetFullPath(pdfOutputPath)); } using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.IO; using IronPdf; public static void ExportRptToPdf(string rptPath, string pdfOutputPath) { ReportDocument rpt = new ReportDocument(); rpt.Load(rptPath); // Set export options DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions() { DiskFileName = @"c:\tmp\html\b.html" }; ExportOptions exportOpts = ExportOptions.CreateExportOptions(); exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; exportOpts.ExportFormatType = ExportFormatType.HTML40; exportOpts.ExportDestinationOptions = diskOpts; // Export report to HTML rpt.Export(); // Convert HTML to PDF var Renderer = new ChromePdfRenderer(); Renderer.RenderingOptions.TextHeader.CenterText = "{url}"; Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"; Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"; Renderer.RenderFileAsPdf(diskOpts.DiskFileName).SaveAs(pdfOutputPath); Console.WriteLine("Report Written To {0}", Path.GetFullPath(pdfOutputPath)); } Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Imports System.IO Imports IronPdf Public Shared Sub ExportRptToPdf(ByVal rptPath As String, ByVal pdfOutputPath As String) Dim rpt As New ReportDocument() rpt.Load(rptPath) ' Set export options Dim diskOpts As New DiskFileDestinationOptions() With {.DiskFileName = "c:\tmp\html\b.html"} Dim exportOpts As ExportOptions = ExportOptions.CreateExportOptions() exportOpts.ExportDestinationType = ExportDestinationType.DiskFile exportOpts.ExportFormatType = ExportFormatType.HTML40 exportOpts.ExportDestinationOptions = diskOpts ' Export report to HTML rpt.Export() ' Convert HTML to PDF Dim Renderer = New ChromePdfRenderer() Renderer.RenderingOptions.TextHeader.CenterText = "{url}" Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}" Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}" Renderer.RenderFileAsPdf(diskOpts.DiskFileName).SaveAs(pdfOutputPath) Console.WriteLine("Report Written To {0}", Path.GetFullPath(pdfOutputPath)) End Sub $vbLabelText $csharpLabel 4. XML Reports Exporting report data as XML is still common despite the prevalence of easier to code formats such as JSON. To style an XML report, the XML may be parsed, and HTML generated 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) { XslCompiledTransform transform = new XslCompiledTransform(); using (XmlReader reader = XmlReader.Create(new StringReader(xslt))) { transform.Load(reader); } StringWriter results = new StringWriter(); using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { transform.Transform(reader, null, results); } ChromePdfRenderer renderer = new ChromePdfRenderer(); renderer.RenderHtmlAsPdf(results.ToString()).SaveAs(pdfOutputPath); } using System.IO; using System.Xml; using System.Xml.Xsl; using IronPdf; public static void ConvertXmlToPdf(string xml, string xslt, string pdfOutputPath) { XslCompiledTransform transform = new XslCompiledTransform(); using (XmlReader reader = XmlReader.Create(new StringReader(xslt))) { transform.Load(reader); } StringWriter results = new StringWriter(); using (XmlReader reader = XmlReader.Create(new StringReader(xml))) { transform.Transform(reader, null, results); } ChromePdfRenderer renderer = new ChromePdfRenderer(); renderer.RenderHtmlAsPdf(results.ToString()).SaveAs(pdfOutputPath); } Imports System.IO Imports System.Xml Imports System.Xml.Xsl Imports IronPdf Public Shared Sub ConvertXmlToPdf(ByVal xml As String, ByVal xslt As String, ByVal pdfOutputPath As String) Dim transform As New XslCompiledTransform() Using reader As XmlReader = XmlReader.Create(New StringReader(xslt)) transform.Load(reader) End Using Dim results As New StringWriter() Using reader As XmlReader = XmlReader.Create(New StringReader(xml)) transform.Transform(reader, Nothing, results) End Using Dim renderer As New ChromePdfRenderer() renderer.RenderHtmlAsPdf(results.ToString()).SaveAs(pdfOutputPath) End Sub $vbLabelText $csharpLabel Please visit the Convert XML to PDF in C# and VB.NET article to learn more. 5. Microsoft SQL Server Reports 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. 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. Render to HTML (Report Builder) 6. Report Security To ensure a PDF report has not been modified or tampered with, it may be digitally signed. This is most easily achieved on a PDF report file after it has been rendered and saved to disk. :path=/static-assets/pdf/content-code-examples/how-to/csharp-pdf-reports-sign-pdf.cs using IronPdf.Signing; // Sign our PDF Report using a p12 or pix digital certificate file new PdfSignature("IronSoftware.pfx", "123456").SignPdfFile("signed.pdf"); Imports IronPdf.Signing ' Sign our PDF Report using a p12 or pix digital certificate file Call (New PdfSignature("IronSoftware.pfx", "123456")).SignPdfFile("signed.pdf") $vbLabelText $csharpLabel 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. 7. 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. using IronPdf; public static void RenderAspxToPdf() { var AspxToPdfOptions = new ChromePdfRenderOptions() { EnableJavaScript = false, // Disable JavaScript for simplicity // ...many more options available }; AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Report.pdf", AspxToPdfOptions); } using IronPdf; public static void RenderAspxToPdf() { var AspxToPdfOptions = new ChromePdfRenderOptions() { EnableJavaScript = false, // Disable JavaScript for simplicity // ...many more options available }; AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Report.pdf", AspxToPdfOptions); } Imports IronPdf Public Shared Sub RenderAspxToPdf() Dim AspxToPdfOptions = New ChromePdfRenderOptions() With {.EnableJavaScript = False} AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.Attachment, "Report.pdf", AspxToPdfOptions) End Sub $vbLabelText $csharpLabel 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. Frequently Asked Questions How do I install the necessary tools for generating PDF reports in C#? You can install IronPDF using NuGet with the command 'Install-Package IronPdf'. Alternatively, you can download the IronPDF DLL manually from the NuGet website. What is the basic methodology for creating a PDF report using a C# library? The basic methodology involves first generating the report as an HTML document and then rendering the HTML as a PDF using IronPDF. How can I convert a Crystal Report to a PDF using C#? You can export the Crystal Report to HTML using the export options in the Crystal Reports Application, and then render the HTML as a PDF using IronPDF. Can XML reports be converted to PDF using a C# library? Yes, XML reports can be styled using XSLT to convert them to HTML, which can then be rendered as a PDF using IronPDF. How can I ensure the security of my PDF reports? You can digitally sign your PDF report to ensure it has not been modified or tampered with after being rendered and saved to disk. Is it possible to generate PDF reports from Microsoft SQL Server using a C# tool? Yes, reports generated from Microsoft SQL Server can be exported as HTML and then converted to PDF using IronPDF. How do I render an ASPX page to PDF in ASP.NET Webforms? You can use the IronPdf.AspxToPdf class on the Form_Load event of an ASP.NET WebForms application to render the page as a PDF. What are the advantages of using HTML for generating PDF reports? Using HTML allows for easy styling and formatting of reports, which can then be accurately converted to PDF format while maintaining the desired layout. Can a C# library handle JavaScript content when rendering HTML to PDF? Yes, IronPDF can handle JavaScript content during the rendering process, although it can be disabled for simplicity if needed. Where can I find more tutorials on using a PDF generation tool for creating reports? You can find more tutorials on the IronPDF website, including a full ASP.NET ASPX to PDF tutorial and other resources for generating PDF reports. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Ready to Get Started? Free NuGet Download Total downloads: 14,631,247 View Licenses