跳過到頁腳內容
產品比較

IronPDF與GroupDocs的比較

Comparing IronPDF and GroupDocs for PDF Document Automation

GroupDocs 和 IronPDF 都是跨平台應用程序,為工程師提供文件自動化的工具,使其能夠創建、編輯、格式化和打印 PDF 文件——當今最廣泛使用的文檔格式之一。 在使用 .NET 和 .NET Core 構建項目时,開發人員必須選擇最適合其項目需求的工具。

開發人員需要對可供使用的庫和工具有充分的了解,PDF 庫也不例外。 每個庫都有其優勢和劣勢,對於開發人員來說,選擇滿足業務和項目需求的工具是至關重要的。

本文將比較兩個最受 .NET 和 .NET Core 開發人員歡迎的 PDF 庫:GroupDocs 和 IronPDF。

什麼是 IronPDF?

IronPDF 是一個基於 C# 的商業 PDF 創建套件,適用於 .NET 平台。 它可以從 HTML、CSS、圖像和 JavaScript 生成 PDF,適合用於網頁應用、安全內聯網、控制台應用、WPF 應用和 MVC 格式的網站。 IronPDF 與所有從版本 4 的 .NET Framework 和 .NET Core 項目兼容。欲了解更多詳情,請訪問 IronPDF 官方網站

什麼是 GroupDocs 庫?

GroupDocs.Editor API 是一個跨平台的 .NET 庫,提供開發人員創建簡單應用程序的能力,這些應用程序與流行的 HTML 編輯器(免費和付費)無縫對接,以轉換、編輯和操作多種文件格式的文檔。 您可以在這裡了解更多關於其功能的資訊。

註釋 PDF 文件

GroupDocs.Annotation

GroupDocs.Annotation for .NET 允許開發人員使用 C#、ASP.NET 和其他 .NET 技術創建執行文件註釋功能的應用程序,例如繪製形狀、添加文本和圖像以及標註文本。 註釋可以被操作並保存回原始文件格式。

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using GroupDocs.Annotation;
using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;

// Initialize list of AnnotationInfo
List<AnnotationInfo> annotations = new List<AnnotationInfo>();

// Initialize text annotation
AnnotationInfo textAnnotation = new AnnotationInfo
{
    Box = new Rectangle((float)265.44, (float)153.86, 206, 36),
    Type = AnnotationType.Text
};

// Add annotation to list
annotations.Add(textAnnotation);

// Get input file stream
using Stream inputFile = new FileStream("D:/input.pdf", FileMode.Open, FileAccess.ReadWrite);

// Export annotation and save the output file
CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Pdf);
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using GroupDocs.Annotation;
using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;

// Initialize list of AnnotationInfo
List<AnnotationInfo> annotations = new List<AnnotationInfo>();

// Initialize text annotation
AnnotationInfo textAnnotation = new AnnotationInfo
{
    Box = new Rectangle((float)265.44, (float)153.86, 206, 36),
    Type = AnnotationType.Text
};

// Add annotation to list
annotations.Add(textAnnotation);

// Get input file stream
using Stream inputFile = new FileStream("D:/input.pdf", FileMode.Open, FileAccess.ReadWrite);

// Export annotation and save the output file
CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Pdf);
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.IO
Imports GroupDocs.Annotation
Imports GroupDocs.Annotation.Models
Imports GroupDocs.Annotation.Models.AnnotationModels

' Initialize list of AnnotationInfo
Private annotations As New List(Of AnnotationInfo)()

' Initialize text annotation
Private textAnnotation As New AnnotationInfo With {
	.Box = New Rectangle(CSng(265.44), CSng(153.86), 206, 36),
	.Type = AnnotationType.Text
}

' Add annotation to list
annotations.Add(textAnnotation)

' Get input file stream
Using inputFile As Stream = New FileStream("D:/input.pdf", FileMode.Open, FileAccess.ReadWrite)
	
	' Export annotation and save the output file
	CommonUtilities.SaveOutputDocument(inputFile, annotations, DocumentType.Pdf)
End Using
$vbLabelText   $csharpLabel

IronPDF

IronPDF 允許用戶通過方法如 IronPdf.PdfDocument.AddTextAnnotation 程序化地註釋 PDF 文件。

using System;
using IronPdf;

class Program
{
    static void Main()
    {
        // Create a PDF annotation object
        PdfDocument pdf = PdfDocument.FromFile("existing.pdf");
        var annotation = new IronPdf.Annotations.TextAnnotation()
        {
            Title = "This is the major title",
            Subject = "This is a subtitle",
            Contents = "This is the long 'sticky note' comment content...",
            Icon = IronPdf.Annotations.TextAnnotation.AnnotationIcon.Help,
            Opacity = 0.9,
            Printable = false,
            Hidden = false,
            OpenByDefault = true,
            ReadOnly = false,
            Rotateable = true
        };

        // Add the annotation "sticky note" to a specific page and location within any new or existing PDF.
        pdf.AddTextAnnotation(annotation, 1, 150, 250);
        pdf.SaveAs("existing.pdf");
    }
}
using System;
using IronPdf;

class Program
{
    static void Main()
    {
        // Create a PDF annotation object
        PdfDocument pdf = PdfDocument.FromFile("existing.pdf");
        var annotation = new IronPdf.Annotations.TextAnnotation()
        {
            Title = "This is the major title",
            Subject = "This is a subtitle",
            Contents = "This is the long 'sticky note' comment content...",
            Icon = IronPdf.Annotations.TextAnnotation.AnnotationIcon.Help,
            Opacity = 0.9,
            Printable = false,
            Hidden = false,
            OpenByDefault = true,
            ReadOnly = false,
            Rotateable = true
        };

        // Add the annotation "sticky note" to a specific page and location within any new or existing PDF.
        pdf.AddTextAnnotation(annotation, 1, 150, 250);
        pdf.SaveAs("existing.pdf");
    }
}
Imports System
Imports IronPdf

Friend Class Program
	Shared Sub Main()
		' Create a PDF annotation object
		Dim pdf As PdfDocument = PdfDocument.FromFile("existing.pdf")
		Dim annotation = New IronPdf.Annotations.TextAnnotation() With {
			.Title = "This is the major title",
			.Subject = "This is a subtitle",
			.Contents = "This is the long 'sticky note' comment content...",
			.Icon = IronPdf.Annotations.TextAnnotation.AnnotationIcon.Help,
			.Opacity = 0.9,
			.Printable = False,
			.Hidden = False,
			.OpenByDefault = True,
			.ReadOnly = False,
			.Rotateable = True
		}

		' Add the annotation "sticky note" to a specific page and location within any new or existing PDF.
		pdf.AddTextAnnotation(annotation, 1, 150, 250)
		pdf.SaveAs("existing.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF 的註釋功能包括顏色選擇、元素調整大小、不透明度設置和文本編輯。

文件類型轉換

在文檔處理中,把某些文件格式轉換為 PDF 是必需的。 這是 GroupDocs 和 IronPDF 的轉換性能比較:

使用 GroupDocs 將文件轉換為 PDF

GroupDocs 轉換 API 無需其他生產力套件即可將各種類型的文檔如 MS Word 和 Excel 轉換為 PDF。

將 XLSB 轉換為 PDF 在 C#

using System;
using GroupDocs.Conversion.Options.Convert;

namespace ConvertXlsbToPdfInCSharp
{
    class Program
    {
        public static void Main(string[] args)
        {
            // Load license
            string licensePath = "GroupDocs.Conversion.lic";
            GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
            lic.SetLicense(licensePath);

            // Load source XLSB for conversion
            var converter = new GroupDocs.Conversion.Converter("sample.xlsb");

            // Conversion options
            var convertOptions = new PdfConvertOptions();

            // Convert XLSB to PDF
            converter.Convert("converted.pdf", convertOptions);
            Console.WriteLine("Conversion complete.");
        }
    }
}
using System;
using GroupDocs.Conversion.Options.Convert;

namespace ConvertXlsbToPdfInCSharp
{
    class Program
    {
        public static void Main(string[] args)
        {
            // Load license
            string licensePath = "GroupDocs.Conversion.lic";
            GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
            lic.SetLicense(licensePath);

            // Load source XLSB for conversion
            var converter = new GroupDocs.Conversion.Converter("sample.xlsb");

            // Conversion options
            var convertOptions = new PdfConvertOptions();

            // Convert XLSB to PDF
            converter.Convert("converted.pdf", convertOptions);
            Console.WriteLine("Conversion complete.");
        }
    }
}
Imports System
Imports GroupDocs.Conversion.Options.Convert

Namespace ConvertXlsbToPdfInCSharp
	Friend Class Program
		Public Shared Sub Main(ByVal args() As String)
			' Load license
			Dim licensePath As String = "GroupDocs.Conversion.lic"
			Dim lic As New GroupDocs.Conversion.License()
			lic.SetLicense(licensePath)

			' Load source XLSB for conversion
			Dim converter = New GroupDocs.Conversion.Converter("sample.xlsb")

			' Conversion options
			Dim convertOptions = New PdfConvertOptions()

			' Convert XLSB to PDF
			converter.Convert("converted.pdf", convertOptions)
			Console.WriteLine("Conversion complete.")
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

將 HTML 轉換為 PDF

GroupDocs 可以將 HTML 文檔轉換為 PDF 格式,非常適合將網絡內容轉換為可打印的存檔。 您可以在這裡查看關於如何將 HTML 轉換為 PDF 的完整教程。

using System;
using GroupDocs.Conversion.Options.Convert;

namespace ConvertHtmlToPdfInCSharp
{
    class Program
    {
        public static void Main(string[] args)
        {
            // Use license
            string licensePath = "GroupDocs.Conversion.lic";
            GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
            lic.SetLicense(licensePath);

            // Load HTML document
            var converter = new GroupDocs.Conversion.Converter("sample.html");

            // PDF options
            var convertOptions = new PdfConvertOptions();

            // Convert HTML to PDF
            converter.Convert("converted.pdf", convertOptions);
            Console.WriteLine("Conversion complete.");
        }
    }
}
using System;
using GroupDocs.Conversion.Options.Convert;

namespace ConvertHtmlToPdfInCSharp
{
    class Program
    {
        public static void Main(string[] args)
        {
            // Use license
            string licensePath = "GroupDocs.Conversion.lic";
            GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License();
            lic.SetLicense(licensePath);

            // Load HTML document
            var converter = new GroupDocs.Conversion.Converter("sample.html");

            // PDF options
            var convertOptions = new PdfConvertOptions();

            // Convert HTML to PDF
            converter.Convert("converted.pdf", convertOptions);
            Console.WriteLine("Conversion complete.");
        }
    }
}
Imports System
Imports GroupDocs.Conversion.Options.Convert

Namespace ConvertHtmlToPdfInCSharp
	Friend Class Program
		Public Shared Sub Main(ByVal args() As String)
			' Use license
			Dim licensePath As String = "GroupDocs.Conversion.lic"
			Dim lic As New GroupDocs.Conversion.License()
			lic.SetLicense(licensePath)

			' Load HTML document
			Dim converter = New GroupDocs.Conversion.Converter("sample.html")

			' PDF options
			Dim convertOptions = New PdfConvertOptions()

			' Convert HTML to PDF
			converter.Convert("converted.pdf", convertOptions)
			Console.WriteLine("Conversion complete.")
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

使用 IronPDF 將文件轉換為 PDF

IronPDF 利用 Chromium 引擎準確地將 HTML 轉換為 PDF。

HTML 轉換為 PDF

IronPDF 可以簡單地將 HTML 內容直接轉換為 PDF。

using IronPdf;

var renderer = new IronPdf.ChromePdfRenderer();
using var pdf = renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
pdf.SaveAs("pixel-perfect.pdf");
using IronPdf;

var renderer = new IronPdf.ChromePdfRenderer();
using var pdf = renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
pdf.SaveAs("pixel-perfect.pdf");
Imports IronPdf

Private renderer = New IronPdf.ChromePdfRenderer()
Private pdf = renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
pdf.SaveAs("pixel-perfect.pdf")
$vbLabelText   $csharpLabel

欲獲得更多轉換功能,請考慮查看IronPDF 的 HTML 到 PDF 轉換器文檔

URL 轉換為 PDF

使用 IronPDF,可以使用自定義瀏覽器引擎輕鬆將整個網頁 URL 轉換為 PDF 格式。

using IronPdf;

IronPdf.ChromePdfRenderer renderer = new IronPdf.ChromePdfRenderer();
using var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");

pdf.SaveAs("url.pdf");
using IronPdf;

IronPdf.ChromePdfRenderer renderer = new IronPdf.ChromePdfRenderer();
using var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");

pdf.SaveAs("url.pdf");
Imports IronPdf

Private renderer As New IronPdf.ChromePdfRenderer()
Private pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/")

pdf.SaveAs("url.pdf")
$vbLabelText   $csharpLabel

有關使用 IronPDF 的 URL 到 PDF 轉換的更多信息,請訪問官方 API 指南

結論

IronPDF 和 GroupDocs 在 PDF 文件處理中各有優勢。 IronPDF 簡單易用,設置要求少且有效的 HTML 呈現。 GroupDocs 提供更廣泛的文件類型支持,適合多樣的轉換需求。 IronPDF 授權透明,選項詳情在IronPDF 定價頁面中可用,提供不同項目大小和需求的選項。

隨著對 PDF 簽名和文檔處理能力的需求不斷增加,了解這些庫的優勢可以幫助開發人員選擇合適的工具。 探索更多關於 Iron Software 的不斷創新和功能這裡

請注意GroupDocs 是其各自所有者的注冊商標。 本網站與 GroupDocs 無關,亦未經其認定或贊助。 所有產品名稱、徽標和品牌均為其各自所有者的財產。 比較僅供信息參考,並反映撰寫時公開可用的信息。

常見問題解答

如何使用 .NET 庫將 HTML 轉換為 PDF?

您可以使用 IronPDF 的 RenderHtmlAsPdf 方法將 HTML 字串轉換為 PDF。若要轉換 HTML 文件,可使用 RenderHtmlFileAsPdf 方法。

IronPDF 提供哪些 PDF 註釋功能?

IronPDF 提供功能強大的註釋功能,允許使用者透過程式為 PDF 添加文字註釋、自訂顏色、調整元素大小、設置不透明度及編輯文字。

哪個 .NET 庫支持更廣泛的文件格式轉換?

GroupDocs 支援更廣泛的文件格式,能夠將 MS Word、Excel 及其他檔案類型轉換為 PDF,使其成為多樣文件轉換需求的理想之選。

IronPDF 如何處理網頁 URL 轉換為 PDF?

IronPDF 可使用其自訂瀏覽器引擎將整個網頁 URL 轉換為 PDF 格式,簡化從線上內容生成 PDF 的過程。

使用 IronPDF 進行 PDF 文件自動化的優勢為何?

IronPDF 提供簡單且易於使用的功能,設定簡便,有效的 HTML 轉換和強大的註釋功能,使其適合用於網頁應用和 MVC 模式網站。

我該如何使用 GroupDocs 為文件添加註釋?

GroupDocs 允許為文件添加各種註釋,包括圖形、文字和圖片,提供跨多種格式的文件操作全面工具。

開發人員在選擇 PDF 庫時應考慮哪些因素?

開發人員應評估其特定專案需求,並比較類似 IronPDF 和 GroupDocs 庫的優勢,以選擇最適合需求的工具。

IronPDF 能否用於 Web 應用中的安全文件創建?

是的,IronPDF 適合於在 Web 應用中生成安全的 PDF 文件,充分利用其精確轉換 HTML、CSS 和 JavaScript 的能力。

Curtis Chau
技術作家

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

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