跳過到頁腳內容
產品比較

在編輯PDF方面iTextSharp與IronPDF之間的比較

PDF (Portable Document Format,可攜式文件格式) 是一種廣泛使用的文件格式,因其能保留文件格式、安全性和可攜性而廣受歡迎。

PDF 檔案已經成為世界上使用最廣泛的文件格式之一,目前有多個函式庫可用於以 C# 語言建立和處理 PDF。

發現如何使用 C# 與 IronPDF 和 iTextSharp 來編輯 PDF 檔案,透過利用這些功能強大的函式庫,讓工作變得簡單直接。

在這篇文章中,我們將比較兩個常用的 C# PDF 操作函式庫:iTextSharp 和 IronPDF。 我們將討論如何使用這兩個函式庫編輯 PDF 檔案,接著我們將探討 IronPDF 與 iTextSharp 相較之下有何優勢,尤其是在輸出列印、效能和價格方面。

iTextSharp DLL 和 IronPDF 庫簡介。

iTextSharp 和 IronPDF的功能和試用資訊可幫助開發人員在 C# 中有效率地處理 PDF 檔案。 這兩個函式庫都提供了廣泛的特性和功能來建立、編輯和處理 PDF 文件。

iTextSharp DLL 是基於 Java 的 iText 函式庫的 C# 移植。 它提供簡單易用的 API,用於建立和操作 PDF 文件。 iTextSharp 是一個開放原始碼的函式庫,可在 AGPL 授權下使用。

IronPDF for .NET 是一個 .NET 函式庫,可使用 C# 來建立、編輯和處理 PDF 檔案。 它提供了一個現代化且直覺的 API 來處理 PDF 文件。 IronPdf 是一個商業函式庫,附有 免費試用版和訂閱選項,可供更廣泛的使用。

比較 iTextSharp 和 IronPDF 函式庫

iTextSharp 和 IronPDF 程式庫都提供了廣泛的特性和功能來建立、編輯和處理 PDF 文件。 然而,與 iTextSharp 相比,IronPDF 有幾項優勢,使其成為用 C# 處理 PDF 文件的首選。

使用 iTextSharp 和 IronPDF 編輯 PDF 檔案

既然我們已經討論過 iTextSharp 與 IronPDF 的差異,讓我們來看看如何使用這兩個函式庫編輯 PDF 檔案。 我們將通過使用 iTextSharp 和 IronPDF 在現有 PDF 文件中新增文字、表單欄位和填寫表單的實例。

使用 iTextSharp 編輯 PDF 檔案

先決條件

在我們開始之前,您將需要下列文件:

1.您的電腦已安裝 Visual Studio。 2.具備 C# 程式語言的基本知識。

  1. 在專案中安裝 iTextSharp 函式庫。

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 1 - 在 C# 中使用 iTextSharp 創建 PDF.

若要在專案中安裝 iTextSharp 函式庫,您可以使用 NuGet 套件管理程式。 開啟您的 Visual Studio 專案,在"解決方案總管"中的專案名稱上按一下滑鼠右鍵。 從上下文功能表中選擇"管理 NuGet 套件"。 在 NuGet 套件管理員中,搜尋"iTextSharp"並安裝最新版本的套件。

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 2 - 探索如何在 ASP.NET C# 中使用 iTextSharp

建立新的 PDF 檔案

若要使用 iTextSharp 建立新的 PDF 檔案,我們需要建立"Document"類別的新實例,並傳送一個新的 FileStream 物件給它的建構器。 以下是一個範例:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using System.IO;

// Create a new PDF document
using (var writer = new PdfWriter(new FileStream("newfile.pdf", FileMode.Create)))
{
    using (var pdf = new PdfDocument(writer))
    {
        var document = new Document(pdf);

        // Create a header paragraph
        Paragraph header = new Paragraph("HEADER")
            .SetTextAlignment(TextAlignment.CENTER)
            .SetFontSize(16);

        // Add the header to the document
        document.Add(header);

        // Loop through pages and align header text
        for (int i = 1; i <= pdf.GetNumberOfPages(); i++)
        {
            Rectangle pageSize = pdf.GetPage(i).GetPageSize();
            float x = pageSize.GetWidth() / 2;
            float y = pageSize.GetTop() - 20;

            // Add the header text to each page
            document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
        }

        // Set the margins
        document.SetTopMargin(50);
        document.SetBottomMargin(50);
    }
}
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using System.IO;

// Create a new PDF document
using (var writer = new PdfWriter(new FileStream("newfile.pdf", FileMode.Create)))
{
    using (var pdf = new PdfDocument(writer))
    {
        var document = new Document(pdf);

        // Create a header paragraph
        Paragraph header = new Paragraph("HEADER")
            .SetTextAlignment(TextAlignment.CENTER)
            .SetFontSize(16);

        // Add the header to the document
        document.Add(header);

        // Loop through pages and align header text
        for (int i = 1; i <= pdf.GetNumberOfPages(); i++)
        {
            Rectangle pageSize = pdf.GetPage(i).GetPageSize();
            float x = pageSize.GetWidth() / 2;
            float y = pageSize.GetTop() - 20;

            // Add the header text to each page
            document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
        }

        // Set the margins
        document.SetTopMargin(50);
        document.SetBottomMargin(50);
    }
}
Imports iText.Kernel.Pdf
Imports iText.Layout
Imports iText.Layout.Element
Imports iText.Layout.Properties
Imports System.IO

' Create a new PDF document
Using writer = New PdfWriter(New FileStream("newfile.pdf", FileMode.Create))
	Using pdf = New PdfDocument(writer)
		Dim document As New Document(pdf)

		' Create a header paragraph
		Dim header As Paragraph = (New Paragraph("HEADER")).SetTextAlignment(TextAlignment.CENTER).SetFontSize(16)

		' Add the header to the document
		document.Add(header)

		' Loop through pages and align header text
		Dim i As Integer = 1
		Do While i <= pdf.GetNumberOfPages()
			Dim pageSize As Rectangle = pdf.GetPage(i).GetPageSize()
'INSTANT VB WARNING: Instant VB cannot determine whether both operands of this division are integer types - if they are then you should use the VB integer division operator:
			Dim x As Single = pageSize.GetWidth() / 2
			Dim y As Single = pageSize.GetTop() - 20

			' Add the header text to each page
			document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0)
			i += 1
		Loop

		' Set the margins
		document.SetTopMargin(50)
		document.SetBottomMargin(50)
	End Using
End Using
$vbLabelText   $csharpLabel

在上面的程式碼中,我們建立了一個新的 PDF 檔案,名為"newfile.pdf",並在其中加入段落標題。

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 3 - iTextSharp 在 C# 中建立 PDF 的教學

編輯現有的 PDF 檔案

要使用 iTextSharp 編輯現有的 PDF 檔案,您需要一個 PdfReader 物件來讀取現有的 PDF 文件,以及一個 PdfStamper 物件來修改它。 以下是一個範例:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using iText.Html2pdf;
using System.IO;

/**
 * iText URL to PDF
 * anchor-itext-url-to-pdf
 **/
private void ExistingWebURL()
{
    // Initialize PDF writer
    PdfWriter writer = new PdfWriter("wikipedia.pdf");

    // Initialize PDF document
    using PdfDocument pdf = new PdfDocument(writer);

    ConverterProperties properties = new ConverterProperties();
    properties.SetBaseUri("https://en.wikipedia.org/wiki/Portable_Document_Format");

    // Convert HTML to PDF
    Document document = HtmlConverter.ConvertToDocument(
        new FileStream("Test_iText7_1.pdf", FileMode.Open), pdf, properties);

    // Create and add a header paragraph
    Paragraph header = new Paragraph("HEADER")
        .SetTextAlignment(TextAlignment.CENTER)
        .SetFontSize(16);

    document.Add(header);

    // Align header text for each page
    for (int i = 1; i <= pdf.GetNumberOfPages(); i++)
    {
        Rectangle pageSize = pdf.GetPage(i).GetPageSize();
        float x = pageSize.GetWidth() / 2;
        float y = pageSize.GetTop() - 20;

        // Add header text aligned at the top
        document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
    }

    // Set the top and bottom margins
    document.SetTopMargin(50);
    document.SetBottomMargin(50);
    document.Close();
}
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using iText.Html2pdf;
using System.IO;

/**
 * iText URL to PDF
 * anchor-itext-url-to-pdf
 **/
private void ExistingWebURL()
{
    // Initialize PDF writer
    PdfWriter writer = new PdfWriter("wikipedia.pdf");

    // Initialize PDF document
    using PdfDocument pdf = new PdfDocument(writer);

    ConverterProperties properties = new ConverterProperties();
    properties.SetBaseUri("https://en.wikipedia.org/wiki/Portable_Document_Format");

    // Convert HTML to PDF
    Document document = HtmlConverter.ConvertToDocument(
        new FileStream("Test_iText7_1.pdf", FileMode.Open), pdf, properties);

    // Create and add a header paragraph
    Paragraph header = new Paragraph("HEADER")
        .SetTextAlignment(TextAlignment.CENTER)
        .SetFontSize(16);

    document.Add(header);

    // Align header text for each page
    for (int i = 1; i <= pdf.GetNumberOfPages(); i++)
    {
        Rectangle pageSize = pdf.GetPage(i).GetPageSize();
        float x = pageSize.GetWidth() / 2;
        float y = pageSize.GetTop() - 20;

        // Add header text aligned at the top
        document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
    }

    // Set the top and bottom margins
    document.SetTopMargin(50);
    document.SetBottomMargin(50);
    document.Close();
}
Imports iText.Kernel.Pdf
Imports iText.Layout
Imports iText.Layout.Element
Imports iText.Layout.Properties
Imports iText.Html2pdf
Imports System.IO

'''
''' * iText URL to PDF
''' * anchor-itext-url-to-pdf
''' *
Private Sub ExistingWebURL()
	' Initialize PDF writer
	Dim writer As New PdfWriter("wikipedia.pdf")

	' Initialize PDF document
	Using pdf As New PdfDocument(writer)
	
		Dim properties As New ConverterProperties()
		properties.SetBaseUri("https://en.wikipedia.org/wiki/Portable_Document_Format")
	
		' Convert HTML to PDF
		Dim document As Document = HtmlConverter.ConvertToDocument(New FileStream("Test_iText7_1.pdf", FileMode.Open), pdf, properties)
	
		' Create and add a header paragraph
		Dim header As Paragraph = (New Paragraph("HEADER")).SetTextAlignment(TextAlignment.CENTER).SetFontSize(16)
	
		document.Add(header)
	
		' Align header text for each page
		Dim i As Integer = 1
		Do While i <= pdf.GetNumberOfPages()
			Dim pageSize As Rectangle = pdf.GetPage(i).GetPageSize()
'INSTANT VB WARNING: Instant VB cannot determine whether both operands of this division are integer types - if they are then you should use the VB integer division operator:
			Dim x As Single = pageSize.GetWidth() / 2
			Dim y As Single = pageSize.GetTop() - 20
	
			' Add header text aligned at the top
			document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0)
			i += 1
		Loop
	
		' Set the top and bottom margins
		document.SetTopMargin(50)
		document.SetBottomMargin(50)
		document.Close()
	End Using
End Sub
$vbLabelText   $csharpLabel

在此程式碼中,會開啟一個現有的 PDF,我們會以正確的文字對齊方式為其頁面加上標題。

使用 IronPDF 編輯 PDF 文件

IronPDF 是一個功能強大的 C# PDF 函式庫,方便編輯 PDF 文件。 本教程將介紹使用 IronPDF 編輯現有 PDF 檔案的步驟,包括建立新的 PDF 文件、新增頁面、合併 PDF 等。

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 4 - IronPDF 功能概述

先決條件

確保您擁有

  • Visual Studio IDE
  • IronPdf 資料庫

步驟 1:建立新專案

在 Visual Studio 中創建一個新 C# 專案。 選擇"控制台應用程式"專案類型。

步驟 2:安裝 IronPdf

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 5 - 安裝 IronPDF NuGet 套件

使用 NuGet Package Manager 將 IronPDF 函式庫安裝到您的專案中。

// Execute this command in the Package Manager Console
Install-Package IronPdf
// Execute this command in the Package Manager Console
Install-Package IronPdf
SHELL

步驟 3:載入現有的 PDF 文件

使用 PdfDocument 類載入現有的 PDF 文件:

using IronPdf;

// Path to an existing PDF file
var existingPdf = @"C:\path\to\existing\pdf\document.pdf";

// Load the PDF document
var pdfDoc = PdfDocument.FromFile(existingPdf);
using IronPdf;

// Path to an existing PDF file
var existingPdf = @"C:\path\to\existing\pdf\document.pdf";

// Load the PDF document
var pdfDoc = PdfDocument.FromFile(existingPdf);
Imports IronPdf

' Path to an existing PDF file
Private existingPdf = "C:\path\to\existing\pdf\document.pdf"

' Load the PDF document
Private pdfDoc = PdfDocument.FromFile(existingPdf)
$vbLabelText   $csharpLabel

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 6 - 使用 IronPDF 建立 PDF

步驟 4:將新頁面新增至現有的 PDF 文件

要新增頁面:

// Add a new page with default size
var newPage = pdfDoc.AddPage();
newPage.Size = PageSize.Letter;
// Add a new page with default size
var newPage = pdfDoc.AddPage();
newPage.Size = PageSize.Letter;
' Add a new page with default size
Dim newPage = pdfDoc.AddPage()
newPage.Size = PageSize.Letter
$vbLabelText   $csharpLabel

步驟 5:從網站建立 PDF

直接從網頁 URL 生成 PDF。 以下是一個範例:

using IronPdf;

/**
 * IronPDF URL to PDF
 * anchor-ironpdf-website-to-pdf
 **/
private void ExistingWebURL()
{
    // Create PDF from a webpage
    var Renderer = new IronPdf.ChromePdfRenderer();

    // Set rendering options
    Renderer.RenderingOptions.MarginTop = 50; // millimeters
    Renderer.RenderingOptions.MarginBottom = 50;
    Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
    Renderer.RenderingOptions.TextHeader = new TextHeaderFooter()
    {
        CenterText = "{pdf-title}",
        DrawDividerLine = true,
        FontSize = 16
    };
    Renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
    {
        LeftText = "{date} {time}",
        RightText = "Page {page} of {total-pages}",
        DrawDividerLine = true,
        FontSize = 14
    };
    Renderer.RenderingOptions.EnableJavaScript = true;
    Renderer.RenderingOptions.RenderDelay = 500; // milliseconds

    // Render URL as PDF
    using var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");
    PDF.SaveAs("wikipedia.pdf");
}
using IronPdf;

/**
 * IronPDF URL to PDF
 * anchor-ironpdf-website-to-pdf
 **/
private void ExistingWebURL()
{
    // Create PDF from a webpage
    var Renderer = new IronPdf.ChromePdfRenderer();

    // Set rendering options
    Renderer.RenderingOptions.MarginTop = 50; // millimeters
    Renderer.RenderingOptions.MarginBottom = 50;
    Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
    Renderer.RenderingOptions.TextHeader = new TextHeaderFooter()
    {
        CenterText = "{pdf-title}",
        DrawDividerLine = true,
        FontSize = 16
    };
    Renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
    {
        LeftText = "{date} {time}",
        RightText = "Page {page} of {total-pages}",
        DrawDividerLine = true,
        FontSize = 14
    };
    Renderer.RenderingOptions.EnableJavaScript = true;
    Renderer.RenderingOptions.RenderDelay = 500; // milliseconds

    // Render URL as PDF
    using var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");
    PDF.SaveAs("wikipedia.pdf");
}
Imports IronPdf

'''
''' * IronPDF URL to PDF
''' * anchor-ironpdf-website-to-pdf
''' *
Private Sub ExistingWebURL()
	' Create PDF from a webpage
	Dim Renderer = New IronPdf.ChromePdfRenderer()

	' Set rendering options
	Renderer.RenderingOptions.MarginTop = 50 ' millimeters
	Renderer.RenderingOptions.MarginBottom = 50
	Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
	Renderer.RenderingOptions.TextHeader = New TextHeaderFooter() With {
		.CenterText = "{pdf-title}",
		.DrawDividerLine = True,
		.FontSize = 16
	}
	Renderer.RenderingOptions.TextFooter = New TextHeaderFooter() With {
		.LeftText = "{date} {time}",
		.RightText = "Page {page} of {total-pages}",
		.DrawDividerLine = True,
		.FontSize = 14
	}
	Renderer.RenderingOptions.EnableJavaScript = True
	Renderer.RenderingOptions.RenderDelay = 500 ' milliseconds

	' Render URL as PDF
	Dim PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format")
	PDF.SaveAs("wikipedia.pdf")
End Sub
$vbLabelText   $csharpLabel

iTextSharp 與 IronPDF 的差異。

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 7 - iTextSharp 和 IronPDF 之間的選擇

iTextSharp 是一個廣受歡迎的開放源碼函式庫,用於在 C# 中建立、處理和擷取 PDF 文件中的資料。 它有完善的文件記錄,並被廣泛使用。 另一方面,IronPDF 更為現代化,其附加功能和優點使其成為開發人員的更佳選擇。

從 HTML 輸入字串產生 PDF

以下是如何使用 IronPDF 從 HTML 建立 PDF:

using IronPdf;

/**
 * IronPDF HTML to PDF
 * anchor-ironpdf-document-from-html
 **/
private void HTMLString()
{
    // Render HTML to PDF
    var Renderer = new IronPdf.ChromePdfRenderer();
    using var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
    Renderer.RenderingOptions.TextFooter = new HtmlHeaderFooter() 
    { 
        HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"
    };
    var OutputPath = "ChromeHtmlToPdf.pdf";
    PDF.SaveAs(OutputPath);
}
using IronPdf;

/**
 * IronPDF HTML to PDF
 * anchor-ironpdf-document-from-html
 **/
private void HTMLString()
{
    // Render HTML to PDF
    var Renderer = new IronPdf.ChromePdfRenderer();
    using var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
    Renderer.RenderingOptions.TextFooter = new HtmlHeaderFooter() 
    { 
        HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"
    };
    var OutputPath = "ChromeHtmlToPdf.pdf";
    PDF.SaveAs(OutputPath);
}
Imports IronPdf

'''
''' * IronPDF HTML to PDF
''' * anchor-ironpdf-document-from-html
''' *
Private Sub HTMLString()
	' Render HTML to PDF
	Dim Renderer = New IronPdf.ChromePdfRenderer()
	Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>")
	Renderer.RenderingOptions.TextFooter = New HtmlHeaderFooter() With {.HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"}
	Dim OutputPath = "ChromeHtmlToPdf.pdf"
	PDF.SaveAs(OutputPath)
End Sub
$vbLabelText   $csharpLabel

iText 7 HTML 至 PDF

使用 iText 7 將 HTML 文本轉換為 PDF:

using iText.Html2pdf;
using System.IO;

/**
 * iText HTML to PDF
 * anchor-itext-html-to-pdf
 **/
private void HTMLString()
{
    HtmlConverter.ConvertToPdf("<h1>Hello iText7</h1>", new FileStream("iText7HtmlToPdf.pdf", FileMode.Create));
}
using iText.Html2pdf;
using System.IO;

/**
 * iText HTML to PDF
 * anchor-itext-html-to-pdf
 **/
private void HTMLString()
{
    HtmlConverter.ConvertToPdf("<h1>Hello iText7</h1>", new FileStream("iText7HtmlToPdf.pdf", FileMode.Create));
}
Imports iText.Html2pdf
Imports System.IO

'''
''' * iText HTML to PDF
''' * anchor-itext-html-to-pdf
''' *
Private Sub HTMLString()
	HtmlConverter.ConvertToPdf("<h1>Hello iText7</h1>", New FileStream("iText7HtmlToPdf.pdf", FileMode.Create))
End Sub
$vbLabelText   $csharpLabel

效能

IronPDF 的設計比 iTextSharp 更快、更有效率,可以使用更少的資源快速產生 PDF。 這種效率對於大型或複雜的文件至關重要。

定價

iTextSharp 在某些使用情況下需要商業授權,這可能會很昂貴。IronPDF 則提供更經濟實惠的定價模式,並針對不同需求和預算提供多種選項。

授權與定價

iTextSharp 與 IronPDF 的主要差異之一在於其授權與定價模式。

  • iTextSharp:以 AGPL 授權,非開源專案需要商業授權。 商業授權的費用各有不同。
  • IronPDF:提供免費試用,並具備彈性授權,包括開發人員和伺服器授權,適合商業用途。

A Comparison between iTextSharp and IronPDF For Editing PDF:圖 9 - IronPDF 的主要功能

結論

總而言之,雖然 iTextSharp 和 IronPDF 都能以 C# 處理 PDF,但 IronPDF 卻是更多功能、更有效率的選擇。它提供了先進的功能、直覺式 API 以及更佳的效能。 其靈活的定價使其適用於商業專案和較大型的組織。

透過 IronPDF 優異的 HTML 至 PDF 轉換功能,開發人員可以輕鬆產生富媒體或互動內容的報表或文件。 IronPDF 的價格極具成本效益,對於需要為 C# 專案提供功能強大且有效率的 PDF 函式庫的開發人員而言,IronPDF 是絕佳的選擇。

請注意iTextSharp 是其各自擁有者的註冊商標。 本網站與 iTextSharp 無任何關聯、背書或贊助。所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較資料僅供參考,並反映撰寫時的公開資訊。

常見問題解答

如何在 C# 中編輯 PDF 檔案而不遺失格式?

您可以使用 IronPDF 在 C# 中編輯 PDF 檔案,確保格式得以保留。IronPDF 提供先進的功能和現代化的 API,讓您能有效率地操作 PDF。

在 Visual Studio 中安裝 PDF 函式庫涉及哪些步驟?

若要在 Visual Studio 中安裝 IronPDF 之類的 PDF 函式庫,請開啟 NuGet Package Manager,搜尋 IronPDF,然後將套件安裝至您的專案。

如何在 C# 中將網頁 URL 轉換為 PDF?

IronPDF 允許您使用 ChromePdfRenderer 類將網頁 URL 轉換為 PDF,以確保高品質的輸出。

iTextSharp 和 IronPDF 在授權方面有何差異?

iTextSharp 採用 AGPL 授權,非開源專案需要商業授權,而 IronPDF 則提供彈性的授權選項,包括免費試用。

如何使用 C# 將文字新增至現有的 PDF?

使用 IronPDF,您可以在 PdfDocument 物件上使用 AddText 等方法將文字添加到現有的 PDF 中,實現 PDF 的無縫編輯。

與 iTextSharp 相比,使用 IronPDF 有哪些優勢?

IronPDF 提供優異的效能、現代化的 API 以及彈性的價格。它還提供先進的 HTML 至 PDF 轉換功能和更好的輸出品質,使其成為用 C# 編輯 PDF 的首選。

在 C# 專案中開始使用 IronPDF 需要哪些條件?

您需要 Visual Studio IDE 和透過 NuGet Package Manager 安裝的 IronPDF 函式庫,才能開始在 C# 專案中使用 IronPDF。

我可以用 C# 從 HTML 字串建立 PDF 嗎?

是的,IronPDF 允許您使用 RenderHtmlAsPdf 等方法從 HTML 字串建立 PDF,為 HTML 到 PDF 的轉換提供了強大的工具。

是什麼讓 IronPDF 成為 C# 開發人員的多功能工具?

IronPDF 直觀的 API、高效的效能、先進的 HTML 至 PDF 轉換功能,以及符合成本效益的價格,使其成為 C# 開發人員的多用途工具。

開發人員如何在 C# 中確保高品質的 PDF 輸出?

透過使用 IronPDF,開發人員可確保高品質的 PDF 輸出,因為 IronPDF 擁有先進的渲染引擎和專為專業 PDF 操作量身打造的全面功能集。

Curtis Chau
技術作家

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

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