IronPDF ハウツー ASP.NET ASPXファイルをPDFに ASPX Pages to PDF in ASP.NET Curtis Chau 更新日:7月 27, 2025 Download IronPDF NuGet Download テキストの検索と置換 テキストと画像のスタンプ Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English This ASPX to PDF tutorial will guide you step-by-step on how to convert ASPX to PDF. Save an ASPX page as a PDF in ASP.NET web applications. Users should never have to open the ASPX file with the .aspx file extension in Google Chrome. We ask our engineering team to convert ASPX to PDF automatically using .NET code! We never need to press CTRL P! There is a server-based way to convert ASPX internet media and save as PDF. Apply settings including setting file behavior and names, adding headers & footers, changing print options, adding page breaks, combining Async & Multithreading, and more. Quickstart: Convert ASPX to PDF in Seconds Get started with IronPDF to effortlessly convert ASPX files to PDFs. This quick and simple example demonstrates rendering an ASPX page directly into a PDF document with just a few lines of code. Perfect for developers looking to streamline their workflow and enhance their ASP.NET applications. Get started making PDFs with NuGet now: Install IronPDF with NuGet Package Manager PM > Install-Package IronPdf Copy and run this code snippet. IronPdf.AspxToPdf.RenderThisPageAsPdf(); Deploy to test on your live environment Start using IronPDF in your project today with a free trial Free 30 day Trial Minimal Workflow (5 steps) Download the ASPX to PDF C# Library Choose your ASPX pages Convert ASPX file to PDF Apply ASPX to PDF Converter Settings and Add Headers, Footers Create Page Breaks in PDF File How to convert ASPX files to PDF Microsoft Web Form Applications for ASP.NET are commonly used in the development of sophisticated websites, online banking, intranets and accounting systems. One common feature of ASP.NET (ASPX) websites is to generate dynamic PDF files such as invoices, tickets, or management reports for users to download in PDF format. This tutorial shows how to use the IronPDF software component for .NET to turn any ASP.NET web form into a PDF (ASP.NET to PDF). HTML, normally rendered as a web page, will be used to render as a PDF for download or viewing in a web browser. The attached source project will show you how to convert a webpage to PDF in ASP.NET using C#. We achieve this HTML to PDF conversion (convert ASPX to PDF) when rendering webpages using the IronPDF and its AspxToPdf Class. 1. Install the ASPX file Converter Free from IronPDF Visual Studioで、プロジェクトソリューションエクスプローラーを右クリックし「NuGet パッケージの管理…」を選択。 From there simply search for IronPDF and install the latest version... click OK to any dialog boxes that come up. This will work in any C# .NET Framework project from Framework 4.6.2 and above, or .NET Core 2 and above. It will also work just as well in VB.NET projects. Install-Package IronPdf Download IronPDF from NuGet DLL経由でインストール Alternatively, the IronPDF DLL can be downloaded and manually installed to the project or GAC from Download IronPDF Package. Remember to add this statement to the top of any cs class file using IronPDF: using IronPdf; using IronPdf; Imports IronPdf $vbLabelText $csharpLabel 2. Convert ASP.NET Webpages to PDF We start with a normal ASPX "Web Form," which renders as HTML. We later convert the ASPX page to PDF file format. In the attached example source code, we rendered a business invoice "Invoice.aspx," a simple HTML business invoice rendered as an ASP.NET Page. The HTML page contains CSS3 stylesheets and may also include images and javascript. To render this ASP.NET Web Page to a PDF instead of HTML, we need to open the C# (or VB.NET) code and add this to the Page_Load event: :path=/static-assets/pdf/content-code-examples/how-to/aspx-to-pdf-1.cs IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser); IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser) $vbLabelText $csharpLabel This is all that's required; the HTML now renders as a PDF. Hyperlinks, StyleSheets, Images and even HTML forms are preserved. This is very similar to the output if the user printed the HTML to a PDF in their browser themselves. IronPDF is built upon Chromium web browser technology that powers Google Chrome. The entire C# code reads like this in full: Convert The ASPX Page as PDF in Active Server Pages. :path=/static-assets/pdf/content-code-examples/how-to/aspx-to-pdf-2.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using IronPdf; namespace AspxToPdfTutorial { public partial class Invoice : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser); } } } Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports IronPdf Namespace AspxToPdfTutorial Partial Public Class Invoice Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser) End Sub End Class End Namespace $vbLabelText $csharpLabel 3. Apply ASPX File to PDF Converter Settings There are many options to tweak and perfect when we convert an ASPX file to PDF generated using .NET Web Forms. These options are documented in full online at IronPDF API Reference. 3.1. Set PDF File Behavior "InBrowser" file behavior attempts to show the PDF directly in the user's browser. This is not always possible in every web browser, but typically a common feature of modern, standards-compliant browsers. IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser); IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser); IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.InBrowser) $vbLabelText $csharpLabel "Attachment" file behavior causes the PDF to be downloaded. IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment); IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel 3.2. Set PDF File Name We may also set the file name of the PDF document by adding an additional parameter. This means we can control the name of the file when the user decides to download or keep it. When we save the ASPX page as a PDF, this name will be given to the PDF document. IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf"); IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf"); IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf") $vbLabelText $csharpLabel 3.3. Change PDF Print Options We can control the output of the PDF by adding an instance of the IronPdf.ChromePdfRenderer Class. ChromePdfRenderer API Reference :path=/static-assets/pdf/content-code-examples/how-to/aspx-to-pdf-3.cs var AspxToPdfOptions = new IronPdf.ChromePdfRenderOptions() { EnableJavaScript = false, //.. many more options available }; IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", AspxToPdfOptions); Dim AspxToPdfOptions = New IronPdf.ChromePdfRenderOptions() With {.EnableJavaScript = False} IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", AspxToPdfOptions) $vbLabelText $csharpLabel The PDF rendering options available include: CreatePdfFormsFromHtml Turns ASPX form elements into editable PDF forms. CssMediaType Screen or Print CSS Styles and StyleSheets. See our full in-depth tutorial with comparison images. CustomCssUrl Allows a custom CSS style-sheet to be applied to HTML before rendering. May be a local file path, or a remote URL. EnableMathematicalLaTex Enables or disables the rendering of mathematical LaTeX elements. EnableJavaScript Enables JavaScript and JSON to be executed before the page is rendered. Ideal for printing from Ajax / Angular Applications. Also see WaitFor how-to guide. Javascript Specifies a custom JavaScript string to be executed after all HTML has loaded but before PDF rendering. JavascriptMessageListener A method callback to be invoked whenever a browser JavaScript console message becomes available. FirstPageNumber First page number for Header and Footer. The default is 1. TableOfContents Generates a table of contents at the location in the HTML document where an element is found with id "ironpdf-toc". TextHeader Sets the footer content for every PDF page as text. Supports 'mail-merge' and automatically turns URLs into hyperlinks. TextFooter Sets the header content for every PDF page as text. Supports 'mail-merge' and automatically turns URLs into hyperlinks. HtmlHeader Sets the header content for every PDF page using content strings or even HTML. HtmlFooter Sets the footer content for every PDF page using content strings or even HTML. MarginBottom Bottom PDF Paper margin in millimeters. Set to zero for a borderless pdf. MarginLeft Left PDF Paper margin in millimeters. Set to zero for a borderless pdf. MarginRight Right PDF Paper margin in millimeters. Set to zero for a borderless pdf. MarginTop Top PDF Paper margin in millimeters. Set to zero for a borderless pdf. UseMarginsOnHeaderAndFooter Specifies whether to use margin values from the main document when rendering headers and footers. PaperFit: A manager for setting up virtual paper layouts, controlling how content will be laid out on PDF "paper" pages. Includes options for Default Chrome Behavior, Zoomed, Responsive CSS3 Layouts, Scale-To-Page & Continuous Feed style PDF page setups. PaperOrientation The PDF paper orientation. Landscape or Portrait. PageRotation Page rotation from existing document. Full explanation and accompanying code example. PaperSize Set an output paper size for PDF pages using System.Drawing.Printing.PaperKind. SetCustomPaperSizeinCentimeters Sets the paper size in centimeters. SetCustomPaperSizeInInches Sets the paper size in inches. SetCustomPaperSizeinMilimeters Sets the paper size in millimeters. SetCustomPaperSizeinPixelsOrPoints Sets the paper size in screen pixels or printer points. ForcePaperSize Specifies whether to force page sizes to be exactly what is specified via PaperSize by resizing the page after generating a PDF from HTML. PrintHtmlBackgrounds Prints HTML image backgrounds. GrayScale Outputs a greyscale PDF in shades of grey instead of full color. WaitFor A wrapper object that holds configuration for wait-for mechanism. This can use useful when considering the rendering of JavaScript, Ajax, or animations. PageLoad: Default render with no waiting. RenderDelay: Setting an arbitrary waiting time. Fonts: Waits until all the fonts have loaded. JavaScript: Triggering the render with a JavaScript function. HTML elements: Waits for specific HTML elements, such as element IDs, names, tag names, and query selectors to target elements. NetworkIdle: Waiting for network idle (0, 2, or a custom amount). Title PDF Document 'Title' metadata. InputEncoding The input character encoding as a string. UTF-8 is Default for ASP.NET. RequestContext Specifies the request context for the render. Timeout. Render timeout in seconds. 4. Add Headers & Footers to ASPX PDFs Using IronPDF, Headers and Footers can be added to the PDF output. The simplest way to do this is with the TextHeaderFooter class, which supports a basic layout that can easily add dynamic data such as the current time and page numbering. 4.1. ASPX to PDF Header & Footer Example :path=/static-assets/pdf/content-code-examples/how-to/aspx-to-pdf-4.cs using IronSoftware.Drawing; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspxToPdfTutorial { public partial class Invoice : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var AspxToPdfOptions = new IronPdf.ChromePdfRenderOptions() { TextHeader = new IronPdf.TextHeaderFooter() { CenterText = "Invoice", DrawDividerLine = false, Font = FontTypes.Arial, FontSize = 12 }, TextFooter = new IronPdf.TextHeaderFooter() { LeftText = "{date} - {time}", RightText = "Page {page} of {total-pages}", Font = IronSoftware.Drawing.FontTypes.Arial, FontSize = 12, }, }; IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", AspxToPdfOptions); } } } Imports IronSoftware.Drawing Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Namespace AspxToPdfTutorial Partial Public Class Invoice Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim AspxToPdfOptions = New IronPdf.ChromePdfRenderOptions() With { .TextHeader = New IronPdf.TextHeaderFooter() With { .CenterText = "Invoice", .DrawDividerLine = False, .Font = FontTypes.Arial, .FontSize = 12 }, .TextFooter = New IronPdf.TextHeaderFooter() With { .LeftText = "{date} - {time}", .RightText = "Page {page} of {total-pages}", .Font = IronSoftware.Drawing.FontTypes.Arial, .FontSize = 12 } } IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", AspxToPdfOptions) End Sub End Class End Namespace $vbLabelText $csharpLabel Alternatively, we can generate HTML headers and footers using the HtmlHeaderFooter class, which also supports CSS, images, and hyperlinks. :path=/static-assets/pdf/content-code-examples/how-to/aspx-to-pdf-5.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AspxToPdfTutorial { public partial class Invoice : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var AspxToPdfOptions = new IronPdf.ChromePdfRenderOptions() { MarginTop = 50, // make sufficiant space for an HTML header HtmlHeader = new IronPdf.HtmlHeaderFooter() { HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>" } }; IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "MyDocument.pdf", AspxToPdfOptions); } } } Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Namespace AspxToPdfTutorial Partial Public Class Invoice Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim AspxToPdfOptions = New IronPdf.ChromePdfRenderOptions() With { .MarginTop = 50, .HtmlHeader = New IronPdf.HtmlHeaderFooter() With {.HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"} } IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "MyDocument.pdf", AspxToPdfOptions) End Sub End Class End Namespace $vbLabelText $csharpLabel As seen in our examples, we may "merge" dynamic text or HTML into Headers / Footers using placeholders: {page}: for the current page number of the PDF. {total-pages}: as the total number of pages within the PDF. {url}: Web URL from which the PDF document was rendered. {date}: for today's date in a format appropriate to the server's system environment. {time}: for the time in hours:seconds using a 24-hour clock. {html-title}: inserts the title from the head tag of the ASPX web form. {pdf-title}: for the document file name. 5. Apply ASPX File to PDF Tricks: Page Breaks Whereas HTML commonly 'flows' into a long page, PDFs simulate digital paper and are broken into consistent pages. Adding the following code to your ASPX page will automatically create a page-break in the .NET generated PDF. :path=/static-assets/pdf/content-code-examples/how-to/aspx-to-pdf-6.cs <div style='page-break-after: always;'> </div> HTML 6. Combine Async & Multithreading for Performance IronPDF was built for .NET Framework 4.6.2, or .NET Core 2 or above. In Framework 4.6.2 or above projects, ASYNC capabilities can be utilized to improve performance when working with multiple documents. Combining Async with multithreaded CPUs and the Parallel.ForEach command will improve bulk PDF format processing significantly. 7. Watch ASPX to PDF Tutorial Video class="tutorial-segment-title">チュートリアルクイックアクセス Explore this Tutorial on GitHub The code for this C# ASPX-To-PDF project is available in C# and VB.NET on GitHub as an ASP.NET website project. Please go ahead and fork us on GitHub for more help using IronPDF. Feel free to share this with anyone who might be asking, 'How do I Convert ASPX to PDF?' C# ASPX to PDF Website Project Advanced ASP.NET Page to PDF Samples in C# for creating PDFs ASP.NET PDF Examples in VB.NET for creating PDFs チュートリアルクイックアクセス" class="img-responsive add-shadow img-responsive img-popup" src="/img/svgs/github-icon.svg" loading="lazy"> チュートリアルクイックアクセス" class="img-responsive add-shadow img-responsive img-popup" src="/img/svgs/html-to-pdf-icon.svg" loading="lazy"> Download C# PDF Quickstart guide To make developing PDFs in your .NET applications easier, we have compiled a quick-start guide as a PDF document. This "Cheat-Sheet" provides quick access to common functions and examples for generating and editing PDFs in C# and VB.NET, and will help save time getting started using IronPDF in your .NET project. Download View the API Reference Explore the API Reference for IronPDF, outlining the details of all of IronPDF’s features, namespaces, classes, methods fields, and enums. View the IronPDF API Reference チュートリアルクイックアクセス" class="img-responsive add-shadow img-responsive img-popup" src="/img/svgs/documentation.svg" loading="lazy"> よくある質問 C#でASPXページをPDFに変換するにはどうすればよいですか? C#でASPXページをPDFに変換するには、IronPDFライブラリを利用します。まず、NuGetを介してIronPDFをダウンロードし、using IronPdf;をプロジェクトに含めます。Page_Loadイベント内でIronPdf.AspxToPdf.RenderThisPageAsPdf()メソッドを使用して変換を実行します。 ASPXからPDFへの変換にIronPDFを使用する利点は何ですか? IronPDFは、ASPXページをブラウザで手動で開かずにPDFにレンダリングできるようにすることで、ASPXからPDFへの変換プロセスを簡素化します。HTML、CSS、JavaScriptをサポートしており、すべてのページ要素とスタイルがPDFに保持されることを保証します。 ASPXページから生成されたPDFにカスタムのヘッダーとフッターを追加できますか? はい、IronPDFを使用すれば、PDFにカスタムのヘッダーとフッターを追加できます。TextHeaderFooterまたはHtmlHeaderFooterクラスを使用して、必要に応じてヘッダーとフッターを動的に追加しスタイル設定できます。 ASP.NETアプリケーションでのASPXからPDFへの変換のパフォーマンスを最適化する方法は? パフォーマンスを最適化するために、IronPDFは非同期PDF変換とマルチスレッドをサポートしています。これにより、複数のドキュメントを同時に処理でき、特に.NET Framework 4.6.2以降のプロジェクトで効率が向上します。 PDFファイルの動作、例えばブラウザで開くかダウンロードするかを制御することは可能ですか? はい、IronPDFを使用して、'InBrowser' や 'Attachment' などのオプションを設定することでPDFファイルの動作を制御できます。これにより、ユーザーはPDFをブラウザで直接開くか、添付ファイルとしてダウンロードするかを選択できます。 IronPDFを使用してASPXからPDFへの変換を設定するためのステップは何ですか? IronPDFを使用してASPXからPDFへの変換を設定するには、まずNuGetを介してプロジェクトにIronPDFを追加します。その後、必要な名前空間を含め、ASPXページのPage_Loadイベント内でIronPdf.AspxToPdf.RenderThisPageAsPdf()メソッドを使用して変換を開始します。 ASPXからPDFへの変換についてのリソースはありますか? はい、IronPDF APIリファレンス、C# PDFクイックスタートガイド、さまざまなビデオチュートリアルなどのリソースがあります。これらのリソースは、開発者がASPXからPDFへの変換技術を習得するのを支援するための詳細情報や例を提供します。 ハイパーリンクやフォームをPDFに保持するにはどうすればよいですか? IronPDFを使用すると、ASPXページをHTML、CSS、JavaScriptの完全なサポートでPDFにレンダリングして、ハイパーリンクやフォームなどの要素が保持されることを保証します。これにより、動的なコンテンツが正確にPDF形式で表現されます。 ASPXからPDFへの変換に関する一般的な問題をトラブルシューティングできますか? はい、一般的なトラブルシューティングのシナリオには、欠落したCSSやJavaScriptファイルのチェック、IronPDFの正しいセットアップの確保、必要な名前空間とメソッドがコードで正しく実装されていることの確認が含まれます。 ASPXからPDFへの変換プロジェクトのソースコードをどこでダウンロードできますか? IronPDFを使用したASPXからPDFへの変換のソースコードは、圧縮されたVisual Studio Webアプリケーションプロジェクトとしてダウンロードできます。また、GitHub上でC#とVB.NETのプロジェクトのコードを確認できます。 IronPDF は .NET 10 で ASPX から PDF への変換をサポートしていますか? はい。IronPDFは.NET 10と完全に互換性があり、ASPXからPDFへの変換機能は.NET 10プロジェクトで特別な対策を必要とせずに「すぐに」動作します。.NET 10をターゲットとするプロジェクトでは、 IronPdf.AspxToPdf.RenderThisPageAsPdf()と、通常の設定や機能をすべてフルサポートで使用できます。 Curtis Chau 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 準備はいいですか? Nuget ダウンロード 16,154,058 | バージョン: 2025.11 ただ今リリースされました 試用ライセンスキーがメールで送信されました。 総ダウンロード数: 16,154,058 ライセンスを見る