跳過到頁腳內容
使用IRONPDF

如何在ASP.NET中使用C#和IronPDF查看PDF文件

大多數人使用專用的桌面應用程式在電腦上開啟 PDF 文件,但軟體工程師也可以使用 IronPDF 透過 C# 程式設計方式建立、檢視、開啟、閱讀和編輯 PDF 內容。

在 ASP.NET 和 C# 中讀取 PDF 檔案時,IronPDF 被證明是一個非常有用的外掛程式。

您可以下載ASP.NET PDF 示範專案

使用 IronPDF 和 C# 可以快速輕鬆地建立 PDF 文件。

PDF 文件的大部分設計和佈局都可以透過使用現有的 HTML 資源或將這項任務委託給網頁設計人員來完成; 它可以處理將 PDF 生成功能整合到您的應用程式中這項耗時的任務,並自動將準備好的文件轉換為 PDF。 使用 .NET,您可以:

  • 將網頁表單、本地 HTML 頁面和其他網站轉換為 PDF 格式。
  • 允許使用者下載文檔,透過電子郵件與他人分享,或將文檔儲存到雲端。
  • 向客戶開立發票並提供報價; 撰寫報告; 協商合約及其他文件。
  • 使用 ASP.NET、ASP.NET Core、Web Forms、MVC、.NET Framework 和 .NET Core 上的 Web API 以及其他程式語言進行開發。

設定 IronPDF 庫

安裝該庫有兩種方法;

使用 NuGet 套件管理器進行安裝

IronPDF 可以透過 Visual Studio 外掛程式或 NuGet 套件管理器從命令列安裝。開啟控制台,在 Visual Studio 中輸入以下命令:

Install-Package IronPdf

直接從網站下載 DLL 文件

或者,您可以直接從網站取得 DLL 檔案。

請記住,在任何使用 IronPDF 的 cs 類別文件的頂部包含以下指示:

using IronPdf;
using IronPdf;
Imports IronPdf
$vbLabelText   $csharpLabel

查看IronPDF 詳細功能概述

IronPDF是一款必備插件。 立即取得並使用 IronPDF NuGet 套件進行試用

Create a PDF File From an HTML String in .NET C#

在 C# 中,從 HTML 字串建立 PDF 檔案是一種高效且有益的建立新 PDF 檔案的方法。

RenderHtmlAsPdf 函數(來自 ChromePdfRenderer)提供了一種簡單的方法,可以將任何 HTML (HTML5) 字串轉換為 PDF 文檔,這要歸功於 IronPDF DLL 中嵌入的 Google Chromium 引擎版本。

// Create a renderer to convert HTML to PDF
var renderer = new ChromePdfRenderer();

// Convert an HTML string to a PDF
using var renderedPdf = renderer.RenderHtmlAsPdf("<h1>My First HTML to Pdf</h1>");

// Define the output path for the PDF
var outputPath = "My_First_Html.pdf";

// Save the rendered PDF to the specified path
renderedPdf.SaveAs(outputPath);

// Automatically open the newly created PDF
System.Diagnostics.Process.Start(outputPath);
// Create a renderer to convert HTML to PDF
var renderer = new ChromePdfRenderer();

// Convert an HTML string to a PDF
using var renderedPdf = renderer.RenderHtmlAsPdf("<h1>My First HTML to Pdf</h1>");

// Define the output path for the PDF
var outputPath = "My_First_Html.pdf";

// Save the rendered PDF to the specified path
renderedPdf.SaveAs(outputPath);

// Automatically open the newly created PDF
System.Diagnostics.Process.Start(outputPath);
' Create a renderer to convert HTML to PDF
Dim renderer = New ChromePdfRenderer()

' Convert an HTML string to a PDF
Dim renderedPdf = renderer.RenderHtmlAsPdf("<h1>My First HTML to Pdf</h1>")

' Define the output path for the PDF
Dim outputPath = "My_First_Html.pdf"

' Save the rendered PDF to the specified path
renderedPdf.SaveAs(outputPath)

' Automatically open the newly created PDF
System.Diagnostics.Process.Start(outputPath)
$vbLabelText   $csharpLabel

RenderHtmlAsPdf 是一個強大的工具,它完全支援 CSS、JavaScript 和圖片。 如果這些材料儲存在硬碟上,則可能需要設定 RenderHtmlAsPdf 的第二個參數。

以下程式碼將產生一個PDF檔案:

// Render HTML to PDF with a base path for local assets
var renderPdf = renderer.RenderHtmlAsPdf("<img src='image_1.png'/>", @"C:\Newproject");
// Render HTML to PDF with a base path for local assets
var renderPdf = renderer.RenderHtmlAsPdf("<img src='image_1.png'/>", @"C:\Newproject");
' Render HTML to PDF with a base path for local assets
Dim renderPdf = renderer.RenderHtmlAsPdf("<img src='image_1.png'/>", "C:\Newproject")
$vbLabelText   $csharpLabel

所有引用的 CSS 樣式表、圖片和 JavaScript 檔案都將相對於 BaseUrlPath,從而可以保持更有組織性和邏輯性的結構。 當然,您也可以使用網路上提供的圖片、樣式表和資源,例如 Web Fonts、Google Fonts,甚至 jQuery。

使用現有 HTML URL 建立 PDF 文檔

可以使用 C# 有效率地將現有 URL 渲染成 PDF; 這也使得團隊能夠將 PDF 設計和後端 PDF 渲染工作分配到各個部門,這是有益的。

以下程式碼示範如何根據 URL 渲染 endeavorcreative.com 頁面:

// Create a renderer for converting URLs to PDF
var renderer = new ChromePdfRenderer();

// Convert the specified URL to a PDF
using var renderedPdf = renderer.RenderUrlAsPdf("https://endeavorcreative.com/setting-up-wordpress-website-from-scratch/");

// Specify the output path for the PDF
var outputPath = "Url_pdf.pdf";

// Save the PDF to the specified path
renderedPdf.SaveAs(outputPath);

// Open the newly created PDF
System.Diagnostics.Process.Start(outputPath);
// Create a renderer for converting URLs to PDF
var renderer = new ChromePdfRenderer();

// Convert the specified URL to a PDF
using var renderedPdf = renderer.RenderUrlAsPdf("https://endeavorcreative.com/setting-up-wordpress-website-from-scratch/");

// Specify the output path for the PDF
var outputPath = "Url_pdf.pdf";

// Save the PDF to the specified path
renderedPdf.SaveAs(outputPath);

// Open the newly created PDF
System.Diagnostics.Process.Start(outputPath);
' Create a renderer for converting URLs to PDF
Dim renderer = New ChromePdfRenderer()

' Convert the specified URL to a PDF
Dim renderedPdf = renderer.RenderUrlAsPdf("https://endeavorcreative.com/setting-up-wordpress-website-from-scratch/")

' Specify the output path for the PDF
Dim outputPath = "Url_pdf.pdf"

' Save the PDF to the specified path
renderedPdf.SaveAs(outputPath)

' Open the newly created PDF
System.Diagnostics.Process.Start(outputPath)
$vbLabelText   $csharpLabel

因此,生成的 PDF 中保留了所有超連結(HTML 連結)甚至 HTML 表單。

從現有 HTML 文件建立 PDF 文檔

本節介紹如何渲染任何本機 HTML 檔案。文件似乎已使用 file:/ 協定打開,所有相關資源(例如 CSS、圖片和 JavaScript 等)都是如此。

// Create a renderer for existing HTML files
var renderer = new ChromePdfRenderer();

// Render an HTML file to PDF
using var renderedPdf = renderer.RenderHtmlFileAsPdf("Assets/test1.html");

// Specify the output path for the PDF
var outputPath = "test1_pdf.pdf";

// Save the PDF to the specified path
renderedPdf.SaveAs(outputPath);

// Open the newly created PDF
System.Diagnostics.Process.Start(outputPath);
// Create a renderer for existing HTML files
var renderer = new ChromePdfRenderer();

// Render an HTML file to PDF
using var renderedPdf = renderer.RenderHtmlFileAsPdf("Assets/test1.html");

// Specify the output path for the PDF
var outputPath = "test1_pdf.pdf";

// Save the PDF to the specified path
renderedPdf.SaveAs(outputPath);

// Open the newly created PDF
System.Diagnostics.Process.Start(outputPath);
' Create a renderer for existing HTML files
Dim renderer = New ChromePdfRenderer()

' Render an HTML file to PDF
Dim renderedPdf = renderer.RenderHtmlFileAsPdf("Assets/test1.html")

' Specify the output path for the PDF
Dim outputPath = "test1_pdf.pdf"

' Save the PDF to the specified path
renderedPdf.SaveAs(outputPath)

' Open the newly created PDF
System.Diagnostics.Process.Start(outputPath)
$vbLabelText   $csharpLabel

這種策略的優點在於,它允許開發人員在創建 HTML 內容的同時,在瀏覽器中測試其效果。 IronPDF的渲染引擎是基於Chrome瀏覽器建構。 因此,建議使用XML 轉換 PDF 轉換,因為可以使用 XSLT 範本將 XML 內容列印到 PDF。

將 ASP.NET Web 表單轉換為 PDF 文件

只需一行程式碼,即可將 ASP.NET 線上表單轉換為 PDF 格式而不是 HTML 格式。 將這行程式碼放在頁面程式碼隱藏檔案的 Page_Load 方法中,使其顯示在頁面上。

ASP.NET Web Forms 應用程式既可以從頭開始創建,也可以從先前的版本開啟。

如果尚未安裝,請安裝 NuGet 套件。

應該使用 using 關鍵字導入 IronPdf 命名空間。

找到要轉換為 PDF 的頁面的後台程式碼。 例如,使用 ASP.NET 的Default.aspx.cs檔案。

RenderThisPageAsPdfAspxToPdf 類別中的一個方法。

using IronPdf;
using System;
using System.Web.UI;

namespace WebApplication7
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Render the current page as a PDF in the browser
            AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.InBrowser);
        }
    }
}
using IronPdf;
using System;
using System.Web.UI;

namespace WebApplication7
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Render the current page as a PDF in the browser
            AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.InBrowser);
        }
    }
}
Imports IronPdf
Imports System
Imports System.Web.UI

Namespace WebApplication7
	Partial Public Class _Default
		Inherits Page

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
			' Render the current page as a PDF in the browser
			AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.InBrowser)
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

這需要安裝IronPdf.Extensions.ASPX NuGet 套件。 由於 ASPX 已被 MVC 模型取代,因此它在 .NET Core 中不可用。

應用 HTML 模板

對於企業內部網路和網站開發人員來說,能夠建立範本或"批量產生"PDF文件是一項標準必備技能。

IronPDF 庫並非建立 PDF 文件模板,而是利用現有的、經過充分測試的技術來產生 HTML 模板。

如下所示,當 HTML 範本補充來自查詢字串或資料庫的資料時,就會建立一個動態產生的 PDF 檔案。

例如,考慮一下 C# String 類別及其屬性。 Format 方法適用於基本的"郵件合併"操作。

// Basic HTML String Formatting
string formattedString = String.Format("<h1>Hello {0}!</h1>", "World");
// Basic HTML String Formatting
string formattedString = String.Format("<h1>Hello {0}!</h1>", "World");
' Basic HTML String Formatting
Dim formattedString As String = String.Format("<h1>Hello {0}!</h1>", "World")
$vbLabelText   $csharpLabel

由於 HTML 檔案可能非常龐大,因此通常會使用任意佔位符,例如 [[NAME]],然後用實際資料取代它們。

以下範例將產生三個 PDF 文檔,每個文檔都將為不同的使用者進行自訂。

// Define an HTML template with a placeholder
var htmlTemplate = "<p>[[NAME]]</p>";

// Sample data to replace placeholders
var names = new[] { "John", "James", "Jenny" };

// Create a new PDF for each name
foreach (var name in names)
{
    // Replace placeholder with actual name
    var htmlInstance = htmlTemplate.Replace("[[NAME]]", name);

    // Create a renderer and render the HTML as PDF
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderHtmlAsPdf(htmlInstance);

    // Save the PDF with the name in the filename
    pdf.SaveAs($"{name}.pdf");
}
// Define an HTML template with a placeholder
var htmlTemplate = "<p>[[NAME]]</p>";

// Sample data to replace placeholders
var names = new[] { "John", "James", "Jenny" };

// Create a new PDF for each name
foreach (var name in names)
{
    // Replace placeholder with actual name
    var htmlInstance = htmlTemplate.Replace("[[NAME]]", name);

    // Create a renderer and render the HTML as PDF
    var renderer = new ChromePdfRenderer();
    using var pdf = renderer.RenderHtmlAsPdf(htmlInstance);

    // Save the PDF with the name in the filename
    pdf.SaveAs($"{name}.pdf");
}
' Define an HTML template with a placeholder
Dim htmlTemplate = "<p>[[NAME]]</p>"

' Sample data to replace placeholders
Dim names = { "John", "James", "Jenny" }

' Create a new PDF for each name
For Each name In names
	' Replace placeholder with actual name
	Dim htmlInstance = htmlTemplate.Replace("[[NAME]]", name)

	' Create a renderer and render the HTML as PDF
	Dim renderer = New ChromePdfRenderer()
	Dim pdf = renderer.RenderHtmlAsPdf(htmlInstance)

	' Save the PDF with the name in the filename
	pdf.SaveAs($"{name}.pdf")
Next name
$vbLabelText   $csharpLabel

ASP.NET MVC 路由:下載此頁面的 PDF 版本

使用 ASP.NET MVC 框架,您可以引導使用者存取 PDF 檔案。

建立新的 ASP.NET MVC 應用程式或將現有 MVC 控制器新增至現有應用程式時,請選擇此選項。 從下拉式功能表中選擇 ASP.NET Web 應用程式 (.NET Framework) > MVC,啟動 Visual Studio 新專案精靈。 或者,您可以開啟一個現有的 MVC 專案。 取代 Controllers 資料夾中 HomeController 檔案中的 Index 方法,或在 Controllers 資料夾中建立新的控制器。

以下是程式碼編寫範例:

using IronPdf;
using System;
using System.Web.Mvc;

namespace WebApplication8.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            // Render a URL as PDF and return it in the response
            using var pdf = HtmlToPdf.StaticRenderUrlAsPdf(new Uri("https://en.wikipedia.org"));
            return File(pdf.BinaryData, "application/pdf", "Wiki.Pdf");
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";
            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";
            return View();
        }
    }
}
using IronPdf;
using System;
using System.Web.Mvc;

namespace WebApplication8.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            // Render a URL as PDF and return it in the response
            using var pdf = HtmlToPdf.StaticRenderUrlAsPdf(new Uri("https://en.wikipedia.org"));
            return File(pdf.BinaryData, "application/pdf", "Wiki.Pdf");
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";
            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";
            return View();
        }
    }
}
Imports IronPdf
Imports System
Imports System.Web.Mvc

Namespace WebApplication8.Controllers
	Public Class HomeController
		Inherits Controller

		Public Function Index() As ActionResult
			' Render a URL as PDF and return it in the response
			Dim pdf = HtmlToPdf.StaticRenderUrlAsPdf(New Uri("https://en.wikipedia.org"))
			Return File(pdf.BinaryData, "application/pdf", "Wiki.Pdf")
		End Function

		Public Function About() As ActionResult
			ViewBag.Message = "Your application description page."
			Return View()
		End Function

		Public Function Contact() As ActionResult
			ViewBag.Message = "Your contact page."
			Return View()
		End Function
	End Class
End Namespace
$vbLabelText   $csharpLabel

為 PDF 文件新增封面頁

如何在 ASP.NET 中使用 C# 和 IronPDF 查看 PDF 文件,圖 1:為 PDF 文件新增封面

IronPDF簡化了PDF文件合併流程。 該技術最常見的應用是在已渲染的 PDF 文件中添加封面或封底。

為此,請準備封面頁,然後使用 PdfDocument 功能。

要合併這兩個文檔,請使用Merge PDF Documents Method

// Create a renderer and render a PDF from a URL
var renderer = new ChromePdfRenderer();
using var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf/");

// Merge the cover page with the rendered PDF
using var merged = PdfDocument.Merge(new PdfDocument("CoverPage.pdf"), pdf);

// Save the merged document
merged.SaveAs("Combined.Pdf");
// Create a renderer and render a PDF from a URL
var renderer = new ChromePdfRenderer();
using var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf/");

// Merge the cover page with the rendered PDF
using var merged = PdfDocument.Merge(new PdfDocument("CoverPage.pdf"), pdf);

// Save the merged document
merged.SaveAs("Combined.Pdf");
' Create a renderer and render a PDF from a URL
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf/")

' Merge the cover page with the rendered PDF
Dim merged = PdfDocument.Merge(New PdfDocument("CoverPage.pdf"), pdf)

' Save the merged document
merged.SaveAs("Combined.Pdf")
$vbLabelText   $csharpLabel

為文件添加浮水印

最後,使用 C# 程式碼可以實現為 PDF 文件添加浮水印; 這可以用來在文件的每一頁上添加免責聲明,聲明它是"機密的"或"樣本"。

// Prepare a stamper with HTML content for the watermark
HtmlStamper stamper = new HtmlStamper("<h2 style='color:red'>SAMPLE</h2>")
{
    HorizontalOffset = new Length(-3, MeasurementUnit.Inch),
    VerticalAlignment = VerticalAlignment.Bottom
};

// Create a renderer and render a PDF from a URL
var renderer = new ChromePdfRenderer();
using var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");

// Apply the watermark to the PDF
pdf.ApplyStamp(stamper);

// Save the watermarked PDF
pdf.SaveAs(@"C:\PathToWatermarked.pdf");
// Prepare a stamper with HTML content for the watermark
HtmlStamper stamper = new HtmlStamper("<h2 style='color:red'>SAMPLE</h2>")
{
    HorizontalOffset = new Length(-3, MeasurementUnit.Inch),
    VerticalAlignment = VerticalAlignment.Bottom
};

// Create a renderer and render a PDF from a URL
var renderer = new ChromePdfRenderer();
using var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");

// Apply the watermark to the PDF
pdf.ApplyStamp(stamper);

// Save the watermarked PDF
pdf.SaveAs(@"C:\PathToWatermarked.pdf");
' Prepare a stamper with HTML content for the watermark
Dim stamper As New HtmlStamper("<h2 style='color:red'>SAMPLE</h2>") With {
	.HorizontalOffset = New Length(-3, MeasurementUnit.Inch),
	.VerticalAlignment = VerticalAlignment.Bottom
}

' Create a renderer and render a PDF from a URL
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")

' Apply the watermark to the PDF
pdf.ApplyStamp(stamper)

' Save the watermarked PDF
pdf.SaveAs("C:\PathToWatermarked.pdf")
$vbLabelText   $csharpLabel

您可以使用密碼保護您的PDF檔案。

當您設定 PDF 文件的密碼屬性時,該文件將被加密,使用者需要提供正確的密碼才能閱讀該文件。 此範例可用於 .NET Core 控制台應用程式。

using IronPdf;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a renderer and render a PDF from HTML
            var renderer = new ChromePdfRenderer();
            using var pdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");

            // Set password to protect the PDF
            pdfDocument.Password = "strong!@#pass&^%word";

            // Save the secured PDF
            pdfDocument.SaveAs("secured.pdf");
        }
    }
}
using IronPdf;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a renderer and render a PDF from HTML
            var renderer = new ChromePdfRenderer();
            using var pdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");

            // Set password to protect the PDF
            pdfDocument.Password = "strong!@#pass&^%word";

            // Save the secured PDF
            pdfDocument.SaveAs("secured.pdf");
        }
    }
}
Imports IronPdf

Namespace ConsoleApp
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			' Create a renderer and render a PDF from HTML
			Dim renderer = New ChromePdfRenderer()
			Dim pdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")

			' Set password to protect the PDF
			pdfDocument.Password = "strong!@#pass&^%word"

			' Save the secured PDF
			pdfDocument.SaveAs("secured.pdf")
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

即使不具備上述優勢,使用 IronPDF 您還可以:

從PDF文件中提取圖像和文字 編輯PDF檔案的HTML內容

建立 PDF 文件是一項極具挑戰性的工作; 有些人可能從未接觸過製作出最優秀文件應該採用的基本概念。 因此,IronPDF 非常有用,因為它簡化了 PDF 的創建,從而改善了從 PDF 和 HTML 創建的文件的原始呈現效果。

根據文件和競爭對手分析中提供的資訊:IronPDF 是創建 PDF 時最有效的工具,它使任何人,包括在辦公室或學校工作的人員,都能輕鬆有效地完成任務。

圖 2:如何在 ASP.NET 中使用 C# 和 IronPDF 檢視 PDF 文件

IronPDF 是一個必備的 .NET 函式庫。 立即取得並使用 IronPDF NuGet 套件進行試用

常見問題解答

如何在 ASP.NET 應用程序中使用 C# 查看 PDF 文件?

您可以使用 IronPDF 在 ASP.NET 應用程序中查看 PDF 文件,方法是將 PDF 渲染為可以嵌入網頁的圖像或 HTML 元素。

將 HTML 頁面轉換為 PDF 在 ASP.NET 中需要哪些步驟?

要在ASP.NET中將HTML頁面轉換為PDF,您可以使用IronPDF的RenderHtmlAsPdf方法,該方法支持CSS和JavaScript以進行準確的渲染。

如何在 C# 中合併多個 PDF 文件?

IronPDF允許您使用PdfDocument.Merge方法合併多個PDF文檔,將不同的PDF文件合併為一個文檔。

是否可以在 ASP.NET 中向 PDF 文檔添加水印?

是的,您可以使用IronPDF在ASP.NET中向PDF文檔添加水印,方法是使用HtmlStamper類來覆蓋自定義HTML內容。

如何在 C# 中實現 PDF 文件的密碼保護?

您可以使用IronPDF在PDF文件上實施密碼保護,通過在PdfDocument上設置Password屬性來加密文件。

IronPDF 可以用於將 ASP.NET Web Forms 轉換為 PDF 嗎?

是的,IronPDF可以通過使用RenderThisPageAsPdf等方法將ASP.NET Web表單轉換為PDF,捕獲整個Web表單作為PDF文檔。

IronPDF 為 PDF 生成在 ASP.NET 中提供了哪些優勢?

IronPDF 提供的優勢包括使用內置的 Google Chromium 引擎準確渲染 HTML、CSS 和 JavaScript,使其成為在 ASP.NET 中生成 PDF 的靈活工具。

如何在我的 ASP.NET 專案中安裝 IronPDF?

您可以通過 NuGet 程式包管理器或直接從 IronPDF 網站下載 DLL 文件,在您的 ASP.NET 專案中安裝 IronPDF。

是什麼使 IronPDF 成為軟體開發人員的寶貴資產?

IronPDF 是軟件開發人員的寶貴資產,因為它簡化了複雜的 PDF 生成任務,並無縫集成到 ASP.NET 應用程序中,以提高 PDF 處理效率。

如何使用 IronPDF 從 C# 中的 URL 創建 PDF?

您可以使用IronPDF的RenderUrlAsPdf方法從URL創建PDF,該方法從URL獲取內容並將其轉換為PDF文檔。

.NET 10支持:IronPDF是否兼容.NET 10並能在ASP.NET中查看PDF文件?

是的—IronPDF完全支持.NET 10,包括使用ASP.NET或ASP.NET Core的網路應用。它可在.NET 10專案中無縫工作,無需特殊配置。您仍然可以使用熟悉的方法,如RenderUrlAsPdf或返回帶MIME類型application/pdfFileStreamResult,就像在早期的.NET版本中一樣。IronPDF被設計為跨平台,並且.NET 10被明確列在支持的框架中。[ironpdf.com](https://ironpdf.com/?utm_source=openai)

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

鋼鐵支援團隊

我們每週 5 天,每天 24 小時在線上。
聊天
電子郵件
打電話給我