跳至頁尾內容
PDF工具

IronPDF對比PDFTron (Apryse):2025年完整C# PDF庫比較

尋找適合您的.NET專案的PDF程式庫? 這份全面比較了IronPDF和PDFTron(現在的Apryse)從功能、定價、效能和開發者體驗分析,幫助您做出明智的決策。 無論您是在構建網頁應用程式、桌面程式或雲端服務,選擇正確的PDF工具包都能顯著影響您的開發速度和專案成功。

快速比較摘要

類別 功能/方面 IronPDF PDFTron (Apryse) 主要優勢
核心架構 設計理念 簡單為先,Chrome V8引擎 企業為重,定制引擎 IronPDF:更快的開發
API複雜性 Simple methods like RenderHtmlAsPdf() IronPDF:顯著減少樣板程式碼
學習曲線 通常為1-2天 通常為1-2週 IronPDF:更快的採用
平台支持 跨平台 原生支持,單一套件 需要多個套件/模塊 IronPDF:更簡單的部署
.NET版本 .NET 10, 9, 8, 7, 6, 5, Core 3.1+, Framework 4.6.2+ 類似支持但需要額外設置 兩者:現代框架支持
HTML到PDF 渲染引擎 完整的Chrome V8引擎 定制引擎(通過HTML2PDF模塊) IronPDF:98%+的瀏覽器保真度
JavaScript支持 完全支持帶渲染延遲 有限的支持 IronPDF:動態內容準備
MS Office支持 DOCX到PDF Built-in DocxToPdfRenderer PDFTron:更好的Office保真度
CAD支持 未提供 DWG、DXF、DGN到PDF PDFTron:CAD工作流程
性能 HTML渲染速度 Chrome引擎渲染;依內容複雜度而異 定制引擎渲染;聯繫Apryse獲取基準測試 依使用案例而異
記憶體使用量 由於嵌入的Chrome過程而較高;支持異步/並行渲染 簡單轉換的開銷較低(定制引擎) Apryse:對於基本使用,記憶體較低
Licensing & Pricing 入門級 Lite:$999(1位開發者,1個專案) 聯繫銷售以獲取定價 IronPDF:透明的定價
企業級 Professional:$2,999(10位開發者) 聯繫銷售以獲取定價 IronPDF:透明公布的定價
支持 包含支持 是的,工程支援24/5 依授權等級而異 IronPDF:包含支持
最佳適用 使用案例 現代網頁應用程式、HTML報告、快速開發 文件繁重的工作流程、CAD/Office轉換 依上下文而異

什麼是IronPDF和PDFTron(Apryse)?

IronPDF概覽

IronPDF是一個全面的.NET PDF程式庫,簡化了開發者對PDF的建立、編輯和操作。 基於Chrome渲染引擎,它擅長將HTML、CSS和JavaScript轉換為像素完美的PDF文件。 這個程式庫的直觀API設計使得開發者可以以最少的程式碼整合PDF功能,非常適合於網頁應用、報告系統和文件自動化。

PDFTron(Apryse)概覽

PDFTron於2023年2月重新命名為Apryse,是一個專注於企業的PDF SDK,提供了廣泛的文件處理能力。 最初為複雜文件工作流程而開發,它提供了對各種文件格式的強大支持,包括Microsoft Office、CAD圖紙和專門的文件型別。PDFTron Systems Inc.,作為全球文件處理技術的領導者,宣布其重新命名為Apryse; 與iText、Windward、Eversign等13家公司一同加入。

如何為PDF生成建立ASP.NET專案?

設置ASP.NET專案以生成PDF需要正確配置,無論您選擇哪個程式庫。 按照這些步驟為IronPDF或PDFTron整合建立基礎:

  1. 打開Visual Studio 2022或更高版本
  2. 點擊"建立新專案"
  3. 選擇"ASP.NET Core Web App"(推薦.NET 6.0或更高)
  4. 選擇您的專案名稱和位置
  5. 根據需要選擇"Web應用程式(Model-View-Controller)"或"Web API"
  6. 確保選擇".NET 8.0"或更高以獲得最佳相容性

Visual Studio新專案對話框顯示ASP.NET Core Web App選項 Visual Studio的新專案對話框顯示PDF程式庫整合的ASP.NET專案模板

對於Web Forms應用程式:

  • 選擇"ASP.NET Web應用程式(.NET Framework)"
  • 從模板選項中選擇"Web Forms"
  • 點擊"建立"來生成專案結構

Visual Studio專案建立向導中的Web Forms模板選擇 選擇Web Forms模板用於具有PDF功能的傳統ASP.NET應用程式

如何在我的C#專案中安裝IronPDF?

IronPDF提供多種安裝方法以適應不同的開發工作流程。 在Visual Studio中,右擊您在解決方案總管中的專案,選擇"管理NuGet套件..."。 從那裡,簡單搜索IronPDF並安裝最新版本。

方法1:使用Visual Studio套件管理器

最簡單的方法是使用Visual Studio內建的NuGet套件管理器:

  1. 右擊解決方案總管中的您的專案
  2. 選擇"管理NuGet套件"
  3. 點擊"瀏覽"並搜尋"IronPDF"
  4. 點擊IronPDF套件上的"安裝"

解決方案總管內容選單顯示管理NuGet套件選項 通過Visual Studio的解決方案總管存取NuGet套件管理器進行IronPDF安裝

Visual Studio專案選單顯示套件管理選項 通過Visual Studio的專案選單以其他方式存取NuGet套件管理器

NuGet套件管理器介面顯示IronPDF安裝 通過NuGet套件管理器安裝IronPDF,具有版本資訊和相依性

方法2:使用套件管理器控制台

對於偏好命令行工具的開發者:

# Open Package Manager Console in Visual Studio
# Tools > NuGet Package Manager > Package Manager Console
Install-Package IronPdf

# For specific version installation
Install-Package IronPdf -Version 2025.7.0
# Open Package Manager Console in Visual Studio
# Tools > NuGet Package Manager > Package Manager Console
Install-Package IronPdf

# For specific version installation
Install-Package IronPdf -Version 2025.7.0
SHELL

方法3:直接下載安裝

對於沒有NuGet存取的環境:

  1. IronPDF官方網站下載
  2. 將ZIP文件解壓縮到您的專案目錄
  3. 在Visual Studio中,右擊"引用"→"新增引用"
  4. 瀏覽並選擇IronPdf.dll

方法4:使用.NET CLI

對於命令行愛好者和CI/CD管線:

# Navigate to your project directory
cd MyProject

# Install IronPDF
dotnet add package IronPdf

# Restore packages
dotnet restore
# Navigate to your project directory
cd MyProject

# Install IronPDF
dotnet add package IronPdf

# Restore packages
dotnet restore
SHELL

如何安裝PDFTron(Apryse)SDK?

由於其模塊化架構和企業專注性,PDFTron安裝涉及更多步驟。 安裝過程會因您的目標平台和所需功能而異。

前提條件

  • Visual Studio 2019或更新版本
  • .NET桌面開發工作負載
  • .NET Framework 4.5.1+ 開發工具
  • PDFTron SDK download

手動整合步驟

  1. 解壓SDK

    # Example extraction path
    PDFNET_BASE = C:/PDFTron/PDFNetDotNet4/
    # Example extraction path
    PDFNET_BASE = C:/PDFTron/PDFNetDotNet4/
    SHELL
  2. 使用授權密鑰初始化

    // Initialize PDFTron with your license key
    pdftron.PDFNet.Initialize("your-license-key-here");
    
    // Note: Demo keys expire after evaluation period
    // Contact Apryse sales for production licenses
    // Initialize PDFTron with your license key
    pdftron.PDFNet.Initialize("your-license-key-here");
    
    // Note: Demo keys expire after evaluation period
    // Contact Apryse sales for production licenses
    ' Initialize PDFTron with your license key
    pdftron.PDFNet.Initialize("your-license-key-here")
    
    ' Note: Demo keys expire after evaluation period
    ' Contact Apryse sales for production licenses
    $vbLabelText   $csharpLabel
  3. 拷貝必要的程式庫

    • PDFNET_BASE拷貝到您的專案目錄
    • 新增對於PDFNet.dll的引用
  4. 配置本地複製屬性

PDFTron將本地複製屬性設為False的Visual Studio 設置PDFNet.dll的本地複製屬性為False以正確部署PDFTron

  1. 更新App.config

    <configuration>
       <runtime>
           <loadFromRemoteSources enabled="true" />
       </runtime>
    </configuration>
    <configuration>
       <runtime>
           <loadFromRemoteSources enabled="true" />
       </runtime>
    </configuration>
    XML
  2. 配置構建後事件

    xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y
    xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y
    SHELL

NuGet安裝(簡化)

使用更簡化的方法:

  1. 開啟NuGet套件管理器
  2. 搜尋"PDFTron.NET.x64"或平台相關套件
  3. 為您的架構安裝適合的套件

PDFTron NuGet套件安裝介面 通過NuGet套件管理器安裝PDFTron具有平台相關套件

相比ComPDFKit的10+型別,PDFTron提供了超過30種型別的注釋。然而,這種廣泛的功能集需要在安裝過程中仔細選擇模塊。

如何使用這些程式庫將URL轉換為PDF?

這兩個程式庫都提供URL到PDF的轉換,但方式和能力不同。 讓我們來看看每個的實施細節和性能特徵。

使用IronPDF將URL轉換為PDF

IronPDF的Chrome渲染引擎為現代網頁標準提供了卓越的支持:

using IronPdf;

// Initialize the Chrome renderer with advanced options
var renderer = new ChromePdfRenderer();

// Configure rendering for optimal results
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 20;
renderer.RenderingOptions.MarginBottom = 20;
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.RenderDelay = 1000; // Wait for JS execution

// Handle authentication if needed
renderer.LoginCredentials = new ChromeHttpLoginCredentials() {
    Username = "user@domain.com",
    Password = "secure_password"
};

// Render URL to PDF with full browser capabilities
var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");

// Add metadata for document management
pdf.MetaData.Author = "Development Team";
pdf.MetaData.Title = "Website Export - " + DateTime.Now.ToString("yyyy-MM-dd");

// Save with compression
pdf.CompressImages(90);
pdf.SaveAs("website-export.pdf");
using IronPdf;

// Initialize the Chrome renderer with advanced options
var renderer = new ChromePdfRenderer();

// Configure rendering for optimal results
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 20;
renderer.RenderingOptions.MarginBottom = 20;
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.RenderDelay = 1000; // Wait for JS execution

// Handle authentication if needed
renderer.LoginCredentials = new ChromeHttpLoginCredentials() {
    Username = "user@domain.com",
    Password = "secure_password"
};

// Render URL to PDF with full browser capabilities
var pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");

// Add metadata for document management
pdf.MetaData.Author = "Development Team";
pdf.MetaData.Title = "Website Export - " + DateTime.Now.ToString("yyyy-MM-dd");

// Save with compression
pdf.CompressImages(90);
pdf.SaveAs("website-export.pdf");
Imports IronPdf

' Initialize the Chrome renderer with advanced options
Private renderer = New ChromePdfRenderer()

' Configure rendering for optimal results
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
renderer.RenderingOptions.MarginTop = 20
renderer.RenderingOptions.MarginBottom = 20
renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print
renderer.RenderingOptions.EnableJavaScript = True
renderer.RenderingOptions.RenderDelay = 1000 ' Wait for JS execution

' Handle authentication if needed
renderer.LoginCredentials = New ChromeHttpLoginCredentials() With {
	.Username = "user@domain.com",
	.Password = "secure_password"
}

' Render URL to PDF with full browser capabilities
Dim pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/")

' Add metadata for document management
pdf.MetaData.Author = "Development Team"
pdf.MetaData.Title = "Website Export - " & DateTime.Now.ToString("yyyy-MM-dd")

' Save with compression
pdf.CompressImages(90)
pdf.SaveAs("website-export.pdf")
$vbLabelText   $csharpLabel

IronPDF中的Chrome渲染器處理複雜的場景包括:

  • 帶有大量JavaScript的單頁應用程式(SPA)
  • 帶有媒體查詢的響應設計
  • 網頁字體和外部樣式表
  • AJAX內容載入
  • CSS動畫和過渡

IronPDF支持這些渲染場景開箱即用:nuget.org/packages/IronPdf。 最近的性能改進提升了渲染速度,特別是對於複雜的網頁應用程式。

使用PDFTron(Apryse)將URL轉換為PDF

PDFTron需要HTML2PDF模塊來進行網頁內容轉換:

using pdftron;
using pdftron.PDF;
using pdftron.SDF;

class UrlToPdfConverter 
{
    public static void ConvertUrlToPdf(string url, string outputPath)
    {
        // Initialize PDFTron with license
        PDFNet.Initialize("your-license-key");

        // Create a new PDF document
        using (PDFDoc doc = new PDFDoc())
        {
            // Initialize HTML2PDF converter
            HTML2PDF converter = new HTML2PDF();

            // Configure conversion settings
            HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
            settings.SetPrintBackground(true);
            settings.SetLoadImages(true);

            // Set page dimensions
            converter.SetPaperSize(PrinterMode.PaperSize.e_letter);
            converter.SetMargins(0.5, 0.5, 0.5, 0.5);

            // Insert URL content
            converter.InsertFromURL(url);

            // Perform conversion
            if (converter.Convert(doc))
            {
                // Save the resulting PDF
                doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
                Console.WriteLine($"Successfully converted {url} to {outputPath}");
            }
            else
            {
                Console.WriteLine("Conversion failed");
            }
        }
    }
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;

class UrlToPdfConverter 
{
    public static void ConvertUrlToPdf(string url, string outputPath)
    {
        // Initialize PDFTron with license
        PDFNet.Initialize("your-license-key");

        // Create a new PDF document
        using (PDFDoc doc = new PDFDoc())
        {
            // Initialize HTML2PDF converter
            HTML2PDF converter = new HTML2PDF();

            // Configure conversion settings
            HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
            settings.SetPrintBackground(true);
            settings.SetLoadImages(true);

            // Set page dimensions
            converter.SetPaperSize(PrinterMode.PaperSize.e_letter);
            converter.SetMargins(0.5, 0.5, 0.5, 0.5);

            // Insert URL content
            converter.InsertFromURL(url);

            // Perform conversion
            if (converter.Convert(doc))
            {
                // Save the resulting PDF
                doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
                Console.WriteLine($"Successfully converted {url} to {outputPath}");
            }
            else
            {
                Console.WriteLine("Conversion failed");
            }
        }
    }
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF

Friend Class UrlToPdfConverter
	Public Shared Sub ConvertUrlToPdf(ByVal url As String, ByVal outputPath As String)
		' Initialize PDFTron with license
		PDFNet.Initialize("your-license-key")

		' Create a new PDF document
		Using doc As New PDFDoc()
			' Initialize HTML2PDF converter
			Dim converter As New HTML2PDF()

			' Configure conversion settings
			Dim settings As New HTML2PDF.WebPageSettings()
			settings.SetPrintBackground(True)
			settings.SetLoadImages(True)

			' Set page dimensions
			converter.SetPaperSize(PrinterMode.PaperSize.e_letter)
			converter.SetMargins(0.5, 0.5, 0.5, 0.5)

			' Insert URL content
			converter.InsertFromURL(url)

			' Perform conversion
			If converter.Convert(doc) Then
				' Save the resulting PDF
				doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized)
				Console.WriteLine($"Successfully converted {url} to {outputPath}")
			Else
				Console.WriteLine("Conversion failed")
			End If
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

對於PDFTron HTML2PDF的主要考量:

  • PDFTron 的 SDK 是根據技術範疇(API、功能)和分發範圍(外部還是內部使用者)來報價的。
  • 與瀏覽器引擎相比,JavaScript支持有限
  • 複雜佈局可能需要額外配置
  • 更適合簡單的HTML文件

如何從HTML字串建立PDF?

從HTML字串建立PDF對於生成動態報告、發票和文件至關重要。 這兩個程式庫以不同的方式處理這一問題。

使用IronPDF將HTML字串轉換為PDF

IronPDF在渲染複雜HTML時表現出色,具有完全支持CSS3和JavaScript:

using IronPdf;
using System.Text;

public class HtmlStringToPdfConverter
{
    public static PdfDocument GenerateInvoice(InvoiceData data)
    {
        // Build dynamic HTML with modern CSS
        var html = new StringBuilder();
        html.Append(@"
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset='UTF-8'>
            <style>
                @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');

                body {
                    font-family: 'Roboto', sans-serif;
                    margin: 0;
                    padding: 20px;
                    color: #333;
                }

                .invoice-header {
                    display: flex;
                    justify-content: space-between;
                    border-bottom: 2px solid #007bff;
                    padding-bottom: 20px;
                    margin-bottom: 30px;
                }

                .company-logo {
                    width: 150px;
                    height: auto;
                }

                .invoice-details {
                    text-align: right;
                }

                .invoice-number {
                    font-size: 24px;
                    font-weight: 700;
                    color: #007bff;
                }

                table {
                    width: 100%;
                    border-collapse: collapse;
                    margin-top: 20px;
                }

                th {
                    background-color: #f8f9fa;
                    padding: 12px;
                    text-align: left;
                    border-bottom: 2px solid #dee2e6;
                }

                td {
                    padding: 12px;
                    border-bottom: 1px solid #dee2e6;
                }

                .total-row {
                    font-weight: 700;
                    font-size: 18px;
                    background-color: #e9ecef;
                }

                @media print {
                    body { margin: 0; }
                    .no-print { display: none; }
                }
            </style>
        </head>
        <body>
        ");

        // Add invoice header
        html.Append($@"
            <div class='invoice-header'>
                <div>
                    <img src='data:image/png;base64,{data.CompanyLogoBase64}' class='company-logo' alt='Company Logo'>
                    <h2>{data.CompanyName}</h2>
                    <p>{data.CompanyAddress}</p>
                </div>
                <div class='invoice-details'>
                    <div class='invoice-number'>Invoice #{data.InvoiceNumber}</div>
                    <p>Date: {data.InvoiceDate:yyyy-MM-dd}</p>
                    <p>Due: {data.DueDate:yyyy-MM-dd}</p>
                </div>
            </div>
        ");

        // Add line items table
        html.Append(@"
            <table>
                <thead>
                    <tr>
                        <th>Description</th>
                        <th>Quantity</th>
                        <th>Unit Price</th>
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
        ");

        foreach (var item in data.LineItems)
        {
            html.Append($@"
                <tr>
                    <td>{item.Description}</td>
                    <td>{item.Quantity}</td>
                    <td>${item.UnitPrice:F2}</td>
                    <td>${item.Total:F2}</td>
                </tr>
            ");
        }

        html.Append($@"
                </tbody>
                <tfoot>
                    <tr class='total-row'>
                        <td colspan='3'>Total</td>
                        <td>${data.Total:F2}</td>
                    </tr>
                </tfoot>
            </table>
        </body>
        </html>
        ");

        // Configure renderer for optimal output
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
        renderer.RenderingOptions.EnableJavaScript = true;
        renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

        // Generate PDF with proper base path for assets
        var pdf = renderer.RenderHtmlAsPdf(html.ToString());

        // Add security if needed
        pdf.SecuritySettings.UserPassword = data.CustomerEmail;
        pdf.SecuritySettings.AllowUserPrinting = true;
        pdf.SecuritySettings.AllowUserCopyPasteContent = false;

        return pdf;
    }
}
using IronPdf;
using System.Text;

public class HtmlStringToPdfConverter
{
    public static PdfDocument GenerateInvoice(InvoiceData data)
    {
        // Build dynamic HTML with modern CSS
        var html = new StringBuilder();
        html.Append(@"
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset='UTF-8'>
            <style>
                @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');

                body {
                    font-family: 'Roboto', sans-serif;
                    margin: 0;
                    padding: 20px;
                    color: #333;
                }

                .invoice-header {
                    display: flex;
                    justify-content: space-between;
                    border-bottom: 2px solid #007bff;
                    padding-bottom: 20px;
                    margin-bottom: 30px;
                }

                .company-logo {
                    width: 150px;
                    height: auto;
                }

                .invoice-details {
                    text-align: right;
                }

                .invoice-number {
                    font-size: 24px;
                    font-weight: 700;
                    color: #007bff;
                }

                table {
                    width: 100%;
                    border-collapse: collapse;
                    margin-top: 20px;
                }

                th {
                    background-color: #f8f9fa;
                    padding: 12px;
                    text-align: left;
                    border-bottom: 2px solid #dee2e6;
                }

                td {
                    padding: 12px;
                    border-bottom: 1px solid #dee2e6;
                }

                .total-row {
                    font-weight: 700;
                    font-size: 18px;
                    background-color: #e9ecef;
                }

                @media print {
                    body { margin: 0; }
                    .no-print { display: none; }
                }
            </style>
        </head>
        <body>
        ");

        // Add invoice header
        html.Append($@"
            <div class='invoice-header'>
                <div>
                    <img src='data:image/png;base64,{data.CompanyLogoBase64}' class='company-logo' alt='Company Logo'>
                    <h2>{data.CompanyName}</h2>
                    <p>{data.CompanyAddress}</p>
                </div>
                <div class='invoice-details'>
                    <div class='invoice-number'>Invoice #{data.InvoiceNumber}</div>
                    <p>Date: {data.InvoiceDate:yyyy-MM-dd}</p>
                    <p>Due: {data.DueDate:yyyy-MM-dd}</p>
                </div>
            </div>
        ");

        // Add line items table
        html.Append(@"
            <table>
                <thead>
                    <tr>
                        <th>Description</th>
                        <th>Quantity</th>
                        <th>Unit Price</th>
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
        ");

        foreach (var item in data.LineItems)
        {
            html.Append($@"
                <tr>
                    <td>{item.Description}</td>
                    <td>{item.Quantity}</td>
                    <td>${item.UnitPrice:F2}</td>
                    <td>${item.Total:F2}</td>
                </tr>
            ");
        }

        html.Append($@"
                </tbody>
                <tfoot>
                    <tr class='total-row'>
                        <td colspan='3'>Total</td>
                        <td>${data.Total:F2}</td>
                    </tr>
                </tfoot>
            </table>
        </body>
        </html>
        ");

        // Configure renderer for optimal output
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
        renderer.RenderingOptions.EnableJavaScript = true;
        renderer.RenderingOptions.CreatePdfFormsFromHtml = true;

        // Generate PDF with proper base path for assets
        var pdf = renderer.RenderHtmlAsPdf(html.ToString());

        // Add security if needed
        pdf.SecuritySettings.UserPassword = data.CustomerEmail;
        pdf.SecuritySettings.AllowUserPrinting = true;
        pdf.SecuritySettings.AllowUserCopyPasteContent = false;

        return pdf;
    }
}
Imports IronPdf
Imports System.Text

Public Class HtmlStringToPdfConverter
	Public Shared Function GenerateInvoice(ByVal data As InvoiceData) As PdfDocument
		' Build dynamic HTML with modern CSS
		Dim html = New StringBuilder()
		html.Append("
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset='UTF-8'>
            <style>
                @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');

                body {
                    font-family: 'Roboto', sans-serif;
                    margin: 0;
                    padding: 20px;
                    color: #333;
                }

                .invoice-header {
                    display: flex;
                    justify-content: space-between;
                    border-bottom: 2px solid #007bff;
                    padding-bottom: 20px;
                    margin-bottom: 30px;
                }

                .company-logo {
                    width: 150px;
                    height: auto;
                }

                .invoice-details {
                    text-align: right;
                }

                .invoice-number {
                    font-size: 24px;
                    font-weight: 700;
                    color: #007bff;
                }

                table {
                    width: 100%;
                    border-collapse: collapse;
                    margin-top: 20px;
                }

                th {
                    background-color: #f8f9fa;
                    padding: 12px;
                    text-align: left;
                    border-bottom: 2px solid #dee2e6;
                }

                td {
                    padding: 12px;
                    border-bottom: 1px solid #dee2e6;
                }

                .total-row {
                    font-weight: 700;
                    font-size: 18px;
                    background-color: #e9ecef;
                }

                @media print {
                    body { margin: 0; }
                    .no-print { display: none; }
                }
            </style>
        </head>
        <body>
        ")

		' Add invoice header
		html.Append($"
            <div class='invoice-header'>
                <div>
                    <img src='data:image/png;base64,{data.CompanyLogoBase64}' class='company-logo' alt='Company Logo'>
                    <h2>{data.CompanyName}</h2>
                    <p>{data.CompanyAddress}</p>
                </div>
                <div class='invoice-details'>
                    <div class='invoice-number'>Invoice #{data.InvoiceNumber}</div>
                    <p>Date: {data.InvoiceDate:yyyy-MM-dd}</p>
                    <p>Due: {data.DueDate:yyyy-MM-dd}</p>
                </div>
            </div>
        ")

		' Add line items table
		html.Append("
            <table>
                <thead>
                    <tr>
                        <th>Description</th>
                        <th>Quantity</th>
                        <th>Unit Price</th>
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
        ")

		For Each item In data.LineItems
			html.Append($"
                <tr>
                    <td>{item.Description}</td>
                    <td>{item.Quantity}</td>
                    <td>${item.UnitPrice:F2}</td>
                    <td>${item.Total:F2}</td>
                </tr>
            ")
		Next item

		html.Append($"
                </tbody>
                <tfoot>
                    <tr class='total-row'>
                        <td colspan='3'>Total</td>
                        <td>${data.Total:F2}</td>
                    </tr>
                </tfoot>
            </table>
        </body>
        </html>
        ")

		' Configure renderer for optimal output
		Dim renderer = New ChromePdfRenderer()
		renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print
		renderer.RenderingOptions.EnableJavaScript = True
		renderer.RenderingOptions.CreatePdfFormsFromHtml = True

		' Generate PDF with proper base path for assets
		Dim pdf = renderer.RenderHtmlAsPdf(html.ToString())

		' Add security if needed
		pdf.SecuritySettings.UserPassword = data.CustomerEmail
		pdf.SecuritySettings.AllowUserPrinting = True
		pdf.SecuritySettings.AllowUserCopyPasteContent = False

		Return pdf
	End Function
End Class
$vbLabelText   $csharpLabel

IronPDF的HTML渲染的主要優勢:

  • 完全支援CSS3,包括彈性框和網格佈局
  • Google字體和網頁字體整合
  • JavaScript圖表庫(Chart.js,D3.js)完美渲染
  • 支援響應設計,具有視口控制
  • Base64圖像嵌入 用於自包文件

使用PDFTron(Apryse)將HTML字串轉換為PDF

PDFTron的HTML字串轉換方法:

using pdftron;
using pdftron.PDF;
using pdftron.SDF;

public class PdfTronHtmlConverter
{
    public static void ConvertHtmlString(string htmlContent, string outputPath)
    {
        PDFNet.Initialize("your-license-key");

        using (PDFDoc doc = new PDFDoc())
        {
            // Create HTML2PDF converter instance
            HTML2PDF converter = new HTML2PDF();

            // Configure page settings
            converter.SetPaperSize(PrinterMode.PaperSize.e_letter);
            converter.SetLandscape(false);
            converter.SetMargins(1.0, 1.0, 1.0, 1.0, HTML2PDF.e_inches);

            // Enable images and backgrounds
            HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
            settings.SetPrintBackground(true);
            settings.SetLoadImages(true);
            settings.SetJavaScriptDelay(1000); // Limited JS support

            // Insert HTML content
            converter.InsertFromHtmlString(htmlContent);

            // Convert to PDF
            if (converter.Convert(doc))
            {
                // Post-processing options
                doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
            }
        }
    }
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;

public class PdfTronHtmlConverter
{
    public static void ConvertHtmlString(string htmlContent, string outputPath)
    {
        PDFNet.Initialize("your-license-key");

        using (PDFDoc doc = new PDFDoc())
        {
            // Create HTML2PDF converter instance
            HTML2PDF converter = new HTML2PDF();

            // Configure page settings
            converter.SetPaperSize(PrinterMode.PaperSize.e_letter);
            converter.SetLandscape(false);
            converter.SetMargins(1.0, 1.0, 1.0, 1.0, HTML2PDF.e_inches);

            // Enable images and backgrounds
            HTML2PDF.WebPageSettings settings = new HTML2PDF.WebPageSettings();
            settings.SetPrintBackground(true);
            settings.SetLoadImages(true);
            settings.SetJavaScriptDelay(1000); // Limited JS support

            // Insert HTML content
            converter.InsertFromHtmlString(htmlContent);

            // Convert to PDF
            if (converter.Convert(doc))
            {
                // Post-processing options
                doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
            }
        }
    }
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF

Public Class PdfTronHtmlConverter
	Public Shared Sub ConvertHtmlString(ByVal htmlContent As String, ByVal outputPath As String)
		PDFNet.Initialize("your-license-key")

		Using doc As New PDFDoc()
			' Create HTML2PDF converter instance
			Dim converter As New HTML2PDF()

			' Configure page settings
			converter.SetPaperSize(PrinterMode.PaperSize.e_letter)
			converter.SetLandscape(False)
			converter.SetMargins(1.0, 1.0, 1.0, 1.0, HTML2PDF.e_inches)

			' Enable images and backgrounds
			Dim settings As New HTML2PDF.WebPageSettings()
			settings.SetPrintBackground(True)
			settings.SetLoadImages(True)
			settings.SetJavaScriptDelay(1000) ' Limited JS support

			' Insert HTML content
			converter.InsertFromHtmlString(htmlContent)

			' Convert to PDF
			If converter.Convert(doc) Then
				' Post-processing options
				doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized)
			End If
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

需要考慮的PDFTron HTML限制:

  • 基本的CSS支持(沒有高級佈局)
  • 限制的JavaScript執行
  • 字型嵌入需要額外配置
  • 更適合簡單的文件佈局

如何將ASPX頁面轉換為PDF?

將ASPX頁面轉換為PDF是ASP.NET應用程式的一個常見需求。 IronPDF提供原生支持,而PDFTron則需要變通方案。

使用IronPDF將ASPX轉換為PDF

IronPDF提供無縫ASPX轉換,只需一行程式碼:

using IronPdf;

public partial class InvoicePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Render the current ASPX page as PDF on page load
        if (Request.QueryString["pdf"] == "true")
        {
            // Configure PDF output options
            AspxToPdf.RenderThisPageAsPdf(
                AspxToPdf.FileBehavior.InBrowser,
                "Invoice_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
        }
    }

    protected void ExportToPdfButton_Click(object sender, EventArgs e)
    {
        // Advanced configuration for ASPX to PDF
        IronPdf.AspxToPdf.RenderThisPageAsPdf(
            IronPdf.AspxToPdf.FileBehavior.Attachment,
            "Invoice.pdf",
            new ChromePdfRenderOptions()
            {
                PaperSize = PdfPaperSize.A4,
                MarginTop = 20,
                MarginBottom = 20,
                CssMediaType = PdfCssMediaType.Print,
                EnableJavaScript = true,
                CreatePdfFormsFromHtml = true,
                FitToPaper = true
            });
    }
}
using IronPdf;

public partial class InvoicePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Render the current ASPX page as PDF on page load
        if (Request.QueryString["pdf"] == "true")
        {
            // Configure PDF output options
            AspxToPdf.RenderThisPageAsPdf(
                AspxToPdf.FileBehavior.InBrowser,
                "Invoice_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
        }
    }

    protected void ExportToPdfButton_Click(object sender, EventArgs e)
    {
        // Advanced configuration for ASPX to PDF
        IronPdf.AspxToPdf.RenderThisPageAsPdf(
            IronPdf.AspxToPdf.FileBehavior.Attachment,
            "Invoice.pdf",
            new ChromePdfRenderOptions()
            {
                PaperSize = PdfPaperSize.A4,
                MarginTop = 20,
                MarginBottom = 20,
                CssMediaType = PdfCssMediaType.Print,
                EnableJavaScript = true,
                CreatePdfFormsFromHtml = true,
                FitToPaper = true
            });
    }
}
Imports IronPdf

Partial Public Class InvoicePage
	Inherits System.Web.UI.Page

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
		' Render the current ASPX page as PDF on page load
		If Request.QueryString("pdf") = "true" Then
			' Configure PDF output options
			AspxToPdf.RenderThisPageAsPdf(AspxToPdf.FileBehavior.InBrowser, "Invoice_" & DateTime.Now.ToString("yyyyMMdd") & ".pdf")
		End If
	End Sub

	Protected Sub ExportToPdfButton_Click(ByVal sender As Object, ByVal e As EventArgs)
		' Advanced configuration for ASPX to PDF
		IronPdf.AspxToPdf.RenderThisPageAsPdf(IronPdf.AspxToPdf.FileBehavior.Attachment, "Invoice.pdf", New ChromePdfRenderOptions() With {
			.PaperSize = PdfPaperSize.A4,
			.MarginTop = 20,
			.MarginBottom = 20,
			.CssMediaType = PdfCssMediaType.Print,
			.EnableJavaScript = True,
			.CreatePdfFormsFromHtml = True,
			.FitToPaper = True
		})
	End Sub
End Class
$vbLabelText   $csharpLabel

對於渲染過程的更多控制:

// In Global.asax.cs or Startup.cs
public static void ConfigureAspxToPdf()
{
    // Set global defaults for all ASPX to PDF conversions
    AspxToPdf.GlobalSettings.PaperSize = PdfPaperSize.A4;
    AspxToPdf.GlobalSettings.PrintHtmlBackgrounds = true;
    AspxToPdf.GlobalSettings.EnableJavaScript = true;
    AspxToPdf.GlobalSettings.CssMediaType = PdfCssMediaType.Screen;

    // Custom headers and footers
    AspxToPdf.GlobalSettings.HtmlHeader = new HtmlHeaderFooter()
    {
        HtmlFragment = "<div style='text-align: center; font-size: 12px;'>{page} of {total-pages}</div>",
        Height = 25
    };
}
// In Global.asax.cs or Startup.cs
public static void ConfigureAspxToPdf()
{
    // Set global defaults for all ASPX to PDF conversions
    AspxToPdf.GlobalSettings.PaperSize = PdfPaperSize.A4;
    AspxToPdf.GlobalSettings.PrintHtmlBackgrounds = true;
    AspxToPdf.GlobalSettings.EnableJavaScript = true;
    AspxToPdf.GlobalSettings.CssMediaType = PdfCssMediaType.Screen;

    // Custom headers and footers
    AspxToPdf.GlobalSettings.HtmlHeader = new HtmlHeaderFooter()
    {
        HtmlFragment = "<div style='text-align: center; font-size: 12px;'>{page} of {total-pages}</div>",
        Height = 25
    };
}
' In Global.asax.cs or Startup.cs
Public Shared Sub ConfigureAspxToPdf()
	' Set global defaults for all ASPX to PDF conversions
	AspxToPdf.GlobalSettings.PaperSize = PdfPaperSize.A4
	AspxToPdf.GlobalSettings.PrintHtmlBackgrounds = True
	AspxToPdf.GlobalSettings.EnableJavaScript = True
	AspxToPdf.GlobalSettings.CssMediaType = PdfCssMediaType.Screen

	' Custom headers and footers
	AspxToPdf.GlobalSettings.HtmlHeader = New HtmlHeaderFooter() With {
		.HtmlFragment = "<div style='text-align: center; font-size: 12px;'>{page} of {total-pages}</div>",
		.Height = 25
	}
End Sub
$vbLabelText   $csharpLabel

IronPDF的ASPX到PDF功能保留了:

  • ViewState和表單值
  • 會話狀態資料
  • CSS樣式和佈局
  • 調用JavaScript的內容
  • 主頁面佈局

使用PDFTron的ASPX替代方案

Apryse(PDFTron)沒有提供內建的ASPX到PDF渲染器,類似於IronPDF的AspxToPdf類。 開發者通常通過首先捕獲ASPX頁面輸出以獲得HTML字串來解決此問題:

// Capture ASPX output as HTML, then convert
public void ConvertAspxWithPdfTron()
{
    // Render ASPX to string first
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);

    // Render the page to HTML
    this.RenderControl(hw);
    string htmlContent = sw.ToString();

    // Then use PDFTron's HTML2PDF
    PDFNet.Initialize("your-license-key");

    using (PDFDoc doc = new PDFDoc())
    {
        HTML2PDF converter = new HTML2PDF();
        converter.InsertFromHtmlString(htmlContent);
        converter.Convert(doc);

        // Send to browser
        byte[] pdfBytes = doc.Save(SDFDoc.SaveOptions.e_linearized);
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(pdfBytes);
        Response.End();
    }
}
// Capture ASPX output as HTML, then convert
public void ConvertAspxWithPdfTron()
{
    // Render ASPX to string first
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);

    // Render the page to HTML
    this.RenderControl(hw);
    string htmlContent = sw.ToString();

    // Then use PDFTron's HTML2PDF
    PDFNet.Initialize("your-license-key");

    using (PDFDoc doc = new PDFDoc())
    {
        HTML2PDF converter = new HTML2PDF();
        converter.InsertFromHtmlString(htmlContent);
        converter.Convert(doc);

        // Send to browser
        byte[] pdfBytes = doc.Save(SDFDoc.SaveOptions.e_linearized);
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(pdfBytes);
        Response.End();
    }
}
' Capture ASPX output as HTML, then convert
Public Sub ConvertAspxWithPdfTron()
	' Render ASPX to string first
	Dim sw As New StringWriter()
	Dim hw As New HtmlTextWriter(sw)

	' Render the page to HTML
	Me.RenderControl(hw)
	Dim htmlContent As String = sw.ToString()

	' Then use PDFTron's HTML2PDF
	PDFNet.Initialize("your-license-key")

	Using doc As New PDFDoc()
		Dim converter As New HTML2PDF()
		converter.InsertFromHtmlString(htmlContent)
		converter.Convert(doc)

		' Send to browser
		Dim pdfBytes() As Byte = doc.Save(SDFDoc.SaveOptions.e_linearized)
		Response.ContentType = "application/pdf"
		Response.BinaryWrite(pdfBytes)
		Response.End()
	End Using
End Sub
$vbLabelText   $csharpLabel

如何將圖像轉換為PDF?

將圖像轉換為PDF對於文件歸檔和作品集建立至關重要。 這兩個程式庫提供這一功能,但方法不同。

使用IronPDF將圖像轉換為PDF

IronPDF提供了一個專用的ImageToPdfConverter類用於高效批量處理:

using IronPdf;
using System.IO;
using System.Linq;

public class ImagePdfGenerator
{
    public static void CreatePhotoAlbum(string imageFolder, string outputPath)
    {
        // Get all supported image files
        var supportedExtensions = new[] { ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg" };
        var imageFiles = Directory.GetFiles(imageFolder)
            .Where(f => supportedExtensions.Contains(Path.GetExtension(f).ToLower()))
            .OrderBy(f => f);

        // Convert images to PDF with options
        var pdf = ImageToPdfConverter.ImageToPdf(imageFiles, ImageBehavior.FitToPage);

        // Add metadata
        pdf.MetaData.Title = "Photo Album";
        pdf.MetaData.Author = "Photography Department";
        pdf.MetaData.CreationDate = DateTime.Now;

        // Apply compression for smaller file size
        pdf.CompressImages(80); // 80% quality

        // Save the PDF
        pdf.SaveAs(outputPath);
    }

    public static void CreateThumbnailCatalog(List<ProductImage> images)
    {
        var renderer = new ChromePdfRenderer();

        // Build HTML with image grid
        var html = @"
        <html>
        <head>
            <style>
                .image-grid {
                    display: grid;
                    grid-template-columns: repeat(3, 1fr);
                    gap: 20px;
                    padding: 20px;
                }
                .image-item {
                    text-align: center;
                }
                .image-item img {
                    max-width: 100%;
                    height: 200px;
                    object-fit: cover;
                    border: 1px solid #ddd;
                }
                .image-caption {
                    margin-top: 10px;
                    font-size: 12px;
                }
            </style>
        </head>
        <body>
            <h1>Product Catalog</h1>
            <div class='image-grid'>";

        foreach (var image in images)
        {
            html += $@"
                <div class='image-item'>
                    <img src='data:image/jpeg;base64,{image.Base64Data}' />
                    <div class='image-caption'>{image.ProductName}</div>
                </div>";
        }

        html += "</div></body></html>";

        // Render with optimal settings for images
        renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("product-catalog.pdf");
    }
}
using IronPdf;
using System.IO;
using System.Linq;

public class ImagePdfGenerator
{
    public static void CreatePhotoAlbum(string imageFolder, string outputPath)
    {
        // Get all supported image files
        var supportedExtensions = new[] { ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg" };
        var imageFiles = Directory.GetFiles(imageFolder)
            .Where(f => supportedExtensions.Contains(Path.GetExtension(f).ToLower()))
            .OrderBy(f => f);

        // Convert images to PDF with options
        var pdf = ImageToPdfConverter.ImageToPdf(imageFiles, ImageBehavior.FitToPage);

        // Add metadata
        pdf.MetaData.Title = "Photo Album";
        pdf.MetaData.Author = "Photography Department";
        pdf.MetaData.CreationDate = DateTime.Now;

        // Apply compression for smaller file size
        pdf.CompressImages(80); // 80% quality

        // Save the PDF
        pdf.SaveAs(outputPath);
    }

    public static void CreateThumbnailCatalog(List<ProductImage> images)
    {
        var renderer = new ChromePdfRenderer();

        // Build HTML with image grid
        var html = @"
        <html>
        <head>
            <style>
                .image-grid {
                    display: grid;
                    grid-template-columns: repeat(3, 1fr);
                    gap: 20px;
                    padding: 20px;
                }
                .image-item {
                    text-align: center;
                }
                .image-item img {
                    max-width: 100%;
                    height: 200px;
                    object-fit: cover;
                    border: 1px solid #ddd;
                }
                .image-caption {
                    margin-top: 10px;
                    font-size: 12px;
                }
            </style>
        </head>
        <body>
            <h1>Product Catalog</h1>
            <div class='image-grid'>";

        foreach (var image in images)
        {
            html += $@"
                <div class='image-item'>
                    <img src='data:image/jpeg;base64,{image.Base64Data}' />
                    <div class='image-caption'>{image.ProductName}</div>
                </div>";
        }

        html += "</div></body></html>";

        // Render with optimal settings for images
        renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print;
        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("product-catalog.pdf");
    }
}
Imports IronPdf
Imports System.IO
Imports System.Linq

Public Class ImagePdfGenerator
	Public Shared Sub CreatePhotoAlbum(ByVal imageFolder As String, ByVal outputPath As String)
		' Get all supported image files
		Dim supportedExtensions = { ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg" }
		Dim imageFiles = Directory.GetFiles(imageFolder).Where(Function(f) supportedExtensions.Contains(Path.GetExtension(f).ToLower())).OrderBy(Function(f) f)

		' Convert images to PDF with options
		Dim pdf = ImageToPdfConverter.ImageToPdf(imageFiles, ImageBehavior.FitToPage)

		' Add metadata
		pdf.MetaData.Title = "Photo Album"
		pdf.MetaData.Author = "Photography Department"
		pdf.MetaData.CreationDate = DateTime.Now

		' Apply compression for smaller file size
		pdf.CompressImages(80) ' 80% quality

		' Save the PDF
		pdf.SaveAs(outputPath)
	End Sub

	Public Shared Sub CreateThumbnailCatalog(ByVal images As List(Of ProductImage))
		Dim renderer = New ChromePdfRenderer()

		' Build HTML with image grid
		Dim html = "
        <html>
        <head>
            <style>
                .image-grid {
                    display: grid;
                    grid-template-columns: repeat(3, 1fr);
                    gap: 20px;
                    padding: 20px;
                }
                .image-item {
                    text-align: center;
                }
                .image-item img {
                    max-width: 100%;
                    height: 200px;
                    object-fit: cover;
                    border: 1px solid #ddd;
                }
                .image-caption {
                    margin-top: 10px;
                    font-size: 12px;
                }
            </style>
        </head>
        <body>
            <h1>Product Catalog</h1>
            <div class='image-grid'>"

		For Each image In images
			html &= $"
                <div class='image-item'>
                    <img src='data:image/jpeg;base64,{image.Base64Data}' />
                    <div class='image-caption'>{image.ProductName}</div>
                </div>"
		Next image

		html &= "</div></body></html>"

		' Render with optimal settings for images
		renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Print
		Dim pdf = renderer.RenderHtmlAsPdf(html)
		pdf.SaveAs("product-catalog.pdf")
	End Sub
End Class
$vbLabelText   $csharpLabel

先進的圖像處理特性:

  • SVG到PDF轉換,保留矢量質量
  • 批處理與記憶優化
  • 自定義大小和定位選項
  • EXIF資料保留

使用PDFTron(Apryse)將圖像轉換為PDF

PDFTron使用其轉換API進行圖像處理:

using pdftron;
using pdftron.PDF;
using pdftron.SDF;

public class PdfTronImageConverter
{
    public static void ConvertImageToPdf(string imagePath, string outputPath)
    {
        PDFNet.Initialize("your-license-key");

        using (PDFDoc doc = new PDFDoc())
        {
            // Use Convert API for image to PDF
            pdftron.PDF.Convert.ToPdf(doc, imagePath);

            // Additional image processing
            PageIterator itr = doc.GetPageIterator();
            while (itr.HasNext())
            {
                Page page = itr.Current();

                // Adjust page size to image
                Rect crop_box = page.GetCropBox();
                page.SetMediaBox(crop_box);

                itr.Next();
            }

            // Save optimized PDF
            doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
        }
    }

    public static void CreateMultiPageImagePdf(string[] imagePaths, string outputPath)
    {
        PDFNet.Initialize("your-license-key");

        using (PDFDoc doc = new PDFDoc())
        {
            ElementBuilder builder = new ElementBuilder();
            ElementWriter writer = new ElementWriter();

            foreach (string imagePath in imagePaths)
            {
                // Create a new page for each image
                Page page = doc.PageCreate();
                writer.Begin(page);

                // Add image to page
                Image img = Image.Create(doc, imagePath);
                Element element = builder.CreateImage(img, 0, 0, 612, 792);
                writer.WritePlacedElement(element);

                writer.End();
                doc.PagePushBack(page);
            }

            doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
        }
    }
}
using pdftron;
using pdftron.PDF;
using pdftron.SDF;

public class PdfTronImageConverter
{
    public static void ConvertImageToPdf(string imagePath, string outputPath)
    {
        PDFNet.Initialize("your-license-key");

        using (PDFDoc doc = new PDFDoc())
        {
            // Use Convert API for image to PDF
            pdftron.PDF.Convert.ToPdf(doc, imagePath);

            // Additional image processing
            PageIterator itr = doc.GetPageIterator();
            while (itr.HasNext())
            {
                Page page = itr.Current();

                // Adjust page size to image
                Rect crop_box = page.GetCropBox();
                page.SetMediaBox(crop_box);

                itr.Next();
            }

            // Save optimized PDF
            doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
        }
    }

    public static void CreateMultiPageImagePdf(string[] imagePaths, string outputPath)
    {
        PDFNet.Initialize("your-license-key");

        using (PDFDoc doc = new PDFDoc())
        {
            ElementBuilder builder = new ElementBuilder();
            ElementWriter writer = new ElementWriter();

            foreach (string imagePath in imagePaths)
            {
                // Create a new page for each image
                Page page = doc.PageCreate();
                writer.Begin(page);

                // Add image to page
                Image img = Image.Create(doc, imagePath);
                Element element = builder.CreateImage(img, 0, 0, 612, 792);
                writer.WritePlacedElement(element);

                writer.End();
                doc.PagePushBack(page);
            }

            doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized);
        }
    }
}
Imports pdftron
Imports pdftron.PDF
Imports pdftron.SDF

Public Class PdfTronImageConverter
	Public Shared Sub ConvertImageToPdf(ByVal imagePath As String, ByVal outputPath As String)
		PDFNet.Initialize("your-license-key")

		Using doc As New PDFDoc()
			' Use Convert API for image to PDF
			pdftron.PDF.Convert.ToPdf(doc, imagePath)

			' Additional image processing
			Dim itr As PageIterator = doc.GetPageIterator()
			Do While itr.HasNext()
				Dim page As Page = itr.Current()

				' Adjust page size to image
				Dim crop_box As Rect = page.GetCropBox()
				page.SetMediaBox(crop_box)

				itr.Next()
			Loop

			' Save optimized PDF
			doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized)
		End Using
	End Sub

	Public Shared Sub CreateMultiPageImagePdf(ByVal imagePaths() As String, ByVal outputPath As String)
		PDFNet.Initialize("your-license-key")

		Using doc As New PDFDoc()
			Dim builder As New ElementBuilder()
			Dim writer As New ElementWriter()

			For Each imagePath As String In imagePaths
				' Create a new page for each image
				Dim page As Page = doc.PageCreate()
				writer.Begin(page)

				' Add image to page
				Dim img As Image = Image.Create(doc, imagePath)
				Dim element As Element = builder.CreateImage(img, 0, 0, 612, 792)
				writer.WritePlacedElement(element)

				writer.End()
				doc.PagePushBack(page)
			Next imagePath

			doc.Save(outputPath, SDFDoc.SaveOptions.e_linearized)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

有哪些授權選項和費用?

了解授權對於預算編制和合規非常重要。 這兩個程式庫有著截然不同的定價模式。

IronPDF授權

IronPDF有3種定價版本,從$2,999。 IronPDF的免費試用版也可用。 IronPDF提供了透明的,已發布的定價(截至2026年4月):

授權等級:

  • Lite License: $999

    • 1位開發者
    • 1個位置
    • 1個專案
    • 非常適合個人開發者或小型專案
  • Plus License: $1,499

    • 3位開發者
    • 3個位置
    • 3個專案
    • 完美適合小型團隊
  • Professional License: $2,999

    • 10位開發者
    • 10個位置
    • 10個專案
    • 適合較大的團隊
  • Unlimited License: $5,999
    • 無限開發者
    • 無限位置
    • 無限專案

附加選項:

  • 免版稅再分發:+$2,999(一次性)
  • 提供SaaS/OEM授權
  • Iron Suite包:以2個產品的價格獲得10個產品

所有Team Licenses均不可轉讓,禁止在組織或代理/客戶關係之外共享

PDFTron(Apryse)授權

Apryse(前身為PDFTron)的授權是報價制,沒有公布的定價。 直接聯系Apryse銷售以獲取報價,網址apryse.com/pricing

主要的授權特點:

  • 所有定價都需要直接銷售洽談——無自行服務購買
  • 可能需要單獨的授權的附加模塊(如HTML2PDF、Office轉換)
  • 通常需要複雜的授權談判以進行企業部署
  • 按模塊定價可能會增加總擁有成本

主要區別:

  • IronPDF:永久授權,一次性付款
  • PDFTron:通常是基於訂閱或年度費用
  • IronPDF:所有功能都包含在基礎授權中
  • PDFTron:核心功能加付費附加功能

支援選項如何比較?

開發者支援可以決定專案時程。 這是每個供應商的客戶協助方法。

IronPDF支援

IronPDF在所有授權中包含專業支持:

  • 電子郵件工程支持24/5
  • 直接存取開發團隊
  • 一般響應時間:24-48小時
  • 全面的文件
  • 影片教程和程式碼範例

IronPDF程式庫在Azure WebApps、Functions和WebJobs中運行。 它在Linux和Windows兩個版本中運行,但我推薦Windows版Functions和WebApps,因為經過更充分的測試且更容易安裝。

PDFTron(Apryse)支援

PDFTron的支援依授權等級而異:

  • PDFTron的成本很高。 重要的是對我們的業務而言是合理的,但當與其他PDF網路解決方案進行比較時,這確實是一個障礙。
  • 對於基本授權的論壇式支援
  • 可選的付費支援計劃
  • 偶爾支援可能會缺乏,開發者不得不自行解決。
  • 響應時間依支援等級而異

性能特徵是什麼?

性能影響使用者體驗和伺服器成本。 讓我們來看看真實世界的性能資料。

IronPDF性能

最近的改進顯著提升了IronPDF的性能:

// Optimized batch processing example
public async Task BatchConvertWithPerformanceMonitoring()
{
    var renderer = new ChromePdfRenderer();

    // Configure for performance
    renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Screen;
    renderer.RenderingOptions.RenderDelay = 0; // No delay for static content
    renderer.RenderingOptions.Timeout = 30; // 30 second timeout

    // Enable parallel processing
    var tasks = new List<Task<PdfDocument>>();
    var urls = GetUrlsToConvert();

    // Process in parallel with throttling
    using (var semaphore = new SemaphoreSlim(4)) // Max 4 concurrent
    {
        foreach (var url in urls)
        {
            await semaphore.WaitAsync();

            tasks.Add(Task.Run(async () =>
            {
                try
                {
                    return await renderer.RenderUrlAsPdfAsync(url);
                }
                finally
                {
                    semaphore.Release();
                }
            }));
        }

        var results = await Task.WhenAll(tasks);

        // Merge results if needed
        var merged = PdfDocument.Merge(results);
        merged.SaveAs("batch-output.pdf");
    }
}
// Optimized batch processing example
public async Task BatchConvertWithPerformanceMonitoring()
{
    var renderer = new ChromePdfRenderer();

    // Configure for performance
    renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Screen;
    renderer.RenderingOptions.RenderDelay = 0; // No delay for static content
    renderer.RenderingOptions.Timeout = 30; // 30 second timeout

    // Enable parallel processing
    var tasks = new List<Task<PdfDocument>>();
    var urls = GetUrlsToConvert();

    // Process in parallel with throttling
    using (var semaphore = new SemaphoreSlim(4)) // Max 4 concurrent
    {
        foreach (var url in urls)
        {
            await semaphore.WaitAsync();

            tasks.Add(Task.Run(async () =>
            {
                try
                {
                    return await renderer.RenderUrlAsPdfAsync(url);
                }
                finally
                {
                    semaphore.Release();
                }
            }));
        }

        var results = await Task.WhenAll(tasks);

        // Merge results if needed
        var merged = PdfDocument.Merge(results);
        merged.SaveAs("batch-output.pdf");
    }
}
' Optimized batch processing example
Public Async Function BatchConvertWithPerformanceMonitoring() As Task
	Dim renderer = New ChromePdfRenderer()

	' Configure for performance
	renderer.RenderingOptions.CssMediaType = PdfCssMediaType.Screen
	renderer.RenderingOptions.RenderDelay = 0 ' No delay for static content
	renderer.RenderingOptions.Timeout = 30 ' 30 second timeout

	' Enable parallel processing
	Dim tasks = New List(Of Task(Of PdfDocument))()
	Dim urls = GetUrlsToConvert()

	' Process in parallel with throttling
	Using semaphore = New SemaphoreSlim(4) ' Max 4 concurrent
		For Each url In urls
			Await semaphore.WaitAsync()

			tasks.Add(Task.Run(Async Function()
				Try
					Return Await renderer.RenderUrlAsPdfAsync(url)
				Finally
					semaphore.Release()
				End Try
			End Function))
		Next url

		Dim results = Await Task.WhenAll(tasks)

		' Merge results if needed
		Dim merged = PdfDocument.Merge(results)
		merged.SaveAs("batch-output.pdf")
	End Using
End Function
$vbLabelText   $csharpLabel

性能特徵:

  • 簡單HTML的渲染速度比含有許多外部資源的複雜頁面更快
  • 複雜的HTML與CSS/JS由於完整的Chrome渲染需要更長時間
  • IronPDF確實有Async變體的渲染方法如ironpdf.com/examples/async。 使用Parallel.ForEach是對於我的用例批量渲染Html To PDF表現最好的策略。

PDFTron(Apryse)性能

Apryse的定制引擎通常對於簡單文件轉換開銷較低:

  • 更快於含有限CSS的基本HTML(不需要完整的瀏覽器渲染)
  • 對Office文件轉換有效
  • 相比基於Chrome的渲染,記憶體佔用較低
  • 非常適合大批量簡單文件的工作流程

然而,使用者反映在複雜場景中會出現問題:

  • 偶爾會有bug出現。有時是非常不利的那種,應該已經在QA測試中看到。 修復可能需要一段時間。

現代CSS框架和Bootstrap支持

隨著企業應用越來越多采用現代CSS框架如Bootstrap、Tailwind和Foundation,能夠準確地將這些框架轉換為PDF成為選擇PDF程式庫的重要考量標準。

IronPDF:完整的基於Chromium的框架支持

IronPDF的Chrome V8渲染引擎為所有現代CSS框架和網頁標準提供了全面支持:

  • Bootstrap 5:完整的彈性盒和CSS網格支持以及所有響應式實用工具
  • Bootstrap 4:與卡片元件、導航系統和表單佈局的完全相容性
  • Tailwind CSS:所有實用類、響應式修飾符和JIT編譯模式
  • Foundation:完整的網格系統和元件庫支持
  • 現代CSS3:彈性盒、CSS網格、CSS變數、動畫、變換和過渡
  • JavaScript框架:React、Vue、Angular元件渲染,具有完整的互動支持

生產驗證:Bootstrap主頁官方模板轉換為98%+的瀏覽器保真度。

程式碼範例:企業儀表板與資料表

using IronPdf;

var renderer = new ChromePdfRenderer();

string bootstrapDashboard = @"
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
    <div class='container-fluid py-4'>
        <div class='d-flex justify-content-between align-items-center mb-4'>
            <h1>Sales Dashboard - Q1 2025</h1>
            <span class='badge bg-success fs-5'>+15.3% YoY</span>
        </div>

        <div class='row g-4 mb-4'>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Total Revenue</h6>
                        <h2 class='text-primary'>$1.2M</h2>
                        <small class='text-success'>↑ 12%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>New Customers</h6>
                        <h2 class='text-info'>1,847</h2>
                        <small class='text-success'>↑ 8%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Avg Order Value</h6>
                        <h2 class='text-warning'>$649</h2>
                        <small class='text-danger'>↓ 3%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Conversion Rate</h6>
                        <h2 class='text-success'>3.2%</h2>
                        <small class='text-success'>↑ 0.4%</small>
                    </div>
                </div>
            </div>
        </div>

        <div class='card'>
            <div class='card-header bg-primary text-white'>
                <h5 class='mb-0'>Top Products by Revenue</h5>
            </div>
            <div class='card-body p-0'>
                <table class='table table-striped table-hover mb-0'>
                    <thead class='table-light'>
                        <tr>
                            <th>Product</th>
                            <th>Category</th>
                            <th>Units Sold</th>
                            <th class='text-end'>Revenue</th>
                            <th class='text-end'>Growth</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong>Professional License</strong></td>
                            <td><span class='badge bg-primary'>Software</span></td>
                            <td>1,234</td>
                            <td class='text-end'>$369,000</td>
                            <td class='text-end'><span class='badge bg-success'>+18%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Plus License</strong></td>
                            <td><span class='badge bg-primary'>Software</span></td>
                            <td>2,891</td>
                            <td class='text-end'>$289,000</td>
                            <td class='text-end'><span class='badge bg-success'>+15%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Support Package</strong></td>
                            <td><span class='badge bg-info'>Services</span></td>
                            <td>892</td>
                            <td class='text-end'>$178,000</td>
                            <td class='text-end'><span class='badge bg-success'>+22%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Training Program</strong></td>
                            <td><span class='badge bg-info'>Services</span></td>
                            <td>456</td>
                            <td class='text-end'>$91,000</td>
                            <td class='text-end'><span class='badge bg-warning'>+5%</span></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>";

var pdf = renderer.RenderHtmlAsPdf(bootstrapDashboard);
pdf.SaveAs("sales-dashboard.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

string bootstrapDashboard = @"
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
    <div class='container-fluid py-4'>
        <div class='d-flex justify-content-between align-items-center mb-4'>
            <h1>Sales Dashboard - Q1 2025</h1>
            <span class='badge bg-success fs-5'>+15.3% YoY</span>
        </div>

        <div class='row g-4 mb-4'>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Total Revenue</h6>
                        <h2 class='text-primary'>$1.2M</h2>
                        <small class='text-success'>↑ 12%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>New Customers</h6>
                        <h2 class='text-info'>1,847</h2>
                        <small class='text-success'>↑ 8%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Avg Order Value</h6>
                        <h2 class='text-warning'>$649</h2>
                        <small class='text-danger'>↓ 3%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Conversion Rate</h6>
                        <h2 class='text-success'>3.2%</h2>
                        <small class='text-success'>↑ 0.4%</small>
                    </div>
                </div>
            </div>
        </div>

        <div class='card'>
            <div class='card-header bg-primary text-white'>
                <h5 class='mb-0'>Top Products by Revenue</h5>
            </div>
            <div class='card-body p-0'>
                <table class='table table-striped table-hover mb-0'>
                    <thead class='table-light'>
                        <tr>
                            <th>Product</th>
                            <th>Category</th>
                            <th>Units Sold</th>
                            <th class='text-end'>Revenue</th>
                            <th class='text-end'>Growth</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong>Professional License</strong></td>
                            <td><span class='badge bg-primary'>Software</span></td>
                            <td>1,234</td>
                            <td class='text-end'>$369,000</td>
                            <td class='text-end'><span class='badge bg-success'>+18%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Plus License</strong></td>
                            <td><span class='badge bg-primary'>Software</span></td>
                            <td>2,891</td>
                            <td class='text-end'>$289,000</td>
                            <td class='text-end'><span class='badge bg-success'>+15%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Support Package</strong></td>
                            <td><span class='badge bg-info'>Services</span></td>
                            <td>892</td>
                            <td class='text-end'>$178,000</td>
                            <td class='text-end'><span class='badge bg-success'>+22%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Training Program</strong></td>
                            <td><span class='badge bg-info'>Services</span></td>
                            <td>456</td>
                            <td class='text-end'>$91,000</td>
                            <td class='text-end'><span class='badge bg-warning'>+5%</span></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>";

var pdf = renderer.RenderHtmlAsPdf(bootstrapDashboard);
pdf.SaveAs("sales-dashboard.pdf");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()

Dim bootstrapDashboard As String = "
<!DOCTYPE html>
<html>
<head>
    <link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
</head>
<body>
    <div class='container-fluid py-4'>
        <div class='d-flex justify-content-between align-items-center mb-4'>
            <h1>Sales Dashboard - Q1 2025</h1>
            <span class='badge bg-success fs-5'>+15.3% YoY</span>
        </div>

        <div class='row g-4 mb-4'>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Total Revenue</h6>
                        <h2 class='text-primary'>$1.2M</h2>
                        <small class='text-success'>↑ 12%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>New Customers</h6>
                        <h2 class='text-info'>1,847</h2>
                        <small class='text-success'>↑ 8%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Avg Order Value</h6>
                        <h2 class='text-warning'>$649</h2>
                        <small class='text-danger'>↓ 3%</small>
                    </div>
                </div>
            </div>
            <div class='col-md-3'>
                <div class='card text-center'>
                    <div class='card-body'>
                        <h6 class='text-muted'>Conversion Rate</h6>
                        <h2 class='text-success'>3.2%</h2>
                        <small class='text-success'>↑ 0.4%</small>
                    </div>
                </div>
            </div>
        </div>

        <div class='card'>
            <div class='card-header bg-primary text-white'>
                <h5 class='mb-0'>Top Products by Revenue</h5>
            </div>
            <div class='card-body p-0'>
                <table class='table table-striped table-hover mb-0'>
                    <thead class='table-light'>
                        <tr>
                            <th>Product</th>
                            <th>Category</th>
                            <th>Units Sold</th>
                            <th class='text-end'>Revenue</th>
                            <th class='text-end'>Growth</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong>Professional License</strong></td>
                            <td><span class='badge bg-primary'>Software</span></td>
                            <td>1,234</td>
                            <td class='text-end'>$369,000</td>
                            <td class='text-end'><span class='badge bg-success'>+18%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Plus License</strong></td>
                            <td><span class='badge bg-primary'>Software</span></td>
                            <td>2,891</td>
                            <td class='text-end'>$289,000</td>
                            <td class='text-end'><span class='badge bg-success'>+15%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Support Package</strong></td>
                            <td><span class='badge bg-info'>Services</span></td>
                            <td>892</td>
                            <td class='text-end'>$178,000</td>
                            <td class='text-end'><span class='badge bg-success'>+22%</span></td>
                        </tr>
                        <tr>
                            <td><strong>Training Program</strong></td>
                            <td><span class='badge bg-info'>Services</span></td>
                            <td>456</td>
                            <td class='text-end'>$91,000</td>
                            <td class='text-end'><span class='badge bg-warning'>+5%</span></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>"

Dim pdf = renderer.RenderHtmlAsPdf(bootstrapDashboard)
pdf.SaveAs("sales-dashboard.pdf")
$vbLabelText   $csharpLabel

輸出:一個專業的企業儀表板,帶有Bootstrap的彈性盒度量卡、響應式網格佈局和經過完美重現的資料表格。

PDFTron(Apryse):具有框架限制的HTML2PDF模塊

PDFTron的HTML到PDF轉換由HTML2PDF模塊提供,使用具有特定現代CSS框架限制的定制渲染引擎:

  • 定制引擎:不是基於Chromium的,這意味著CSS3支持是選擇性的而非全面的
  • 彈性盒支持:部分實現,Bootstrap 4/5的彈性盒佈局可能無法正確渲染
  • CSS網格:有限的CSS網格佈局規範支持
  • JavaScript限制:與完整的瀏覽器引擎相比,JavaScript執行有限
  • Bootstrap 3:由於基於表格的佈局,一般比Bootstrap 4/5效果更好
  • 需要框架測試:複雜的Bootstrap元件需要廣泛的測試和潛在的解決方案

根據開發者報告,使用Bootstrap的PDFTron使用者遇到:

  • 基於彈性盒的導航欄渲染與對齊問題
  • 需要進行CSS調整的卡派和網格系統
  • PDF輸出中未被回應的響應式實用工具
  • 需要簡化Bootstrap元件或使用回退CSS

企業考量:對於基於現代Bootstrap版本(4+)的應用,PDFTron可能需要大量的額外開發工作來處理佈局轉換,這有可能抵消其其他性能優勢。 定制引擎的方法意味著您無法獲得與真實瀏覽器相同的渲染保真度。

欲獲得全面的Bootstrap框架支持和測試指南,請參閱Bootstrap & Flexbox CSS指南

何時應選擇每個程式庫?

做出正確選擇取決於您的具體要求和限制。

選擇IronPDF當:

HTML/CSS保真度至關重要

  • 現代網頁應用具有複雜佈局
  • 內容含有大量JavaScript
  • 需要保留的響應式設計

快速開發是優先事項

預算透明度很重要

  • 已公布的定價使得預算準確
  • 沒有意外成本或隱藏費用
  • 包括所有功能在基礎授權中

您需要特定功能

選擇PDFTron(Apryse)當:

企業文件工作流程

  • 符合XFA支持的複雜表單處理
  • CAD文件轉換(DWG,DXF)
  • 高級Office文件處理

性能優先於特性

  • 高批量簡單文件處理
  • 較低的記憶要求
  • 基本的HTML轉換需求

特別的需求

  • 內建的文件查看元件
  • 廣泛(30+)的註釋型別
  • 與傳統系統整合

大型企業環境

  • 專用的支援合約
  • 定制的功能開發
  • 符合性證書

摘要和結論

IronPDF和PDFTron(Apryse) 都是功能完備的PDF程式庫,但它們服務於不同的市場細分和使用案例。

IronPDF在以下方面傑出:

  • 現代網路技術支持(HTML5、CSS3、JavaScript)
  • 對開發者友好的API設計
  • 透明,負擔得起的定價
  • 快速應用程式開發
  • 雲端和容器部署

PDFTron(Apryse)的優勢包括:

  • 企業文件工作流程
  • CAD和專門格式支持
  • 較低的資源消耗
  • 廣泛的註釋能力
  • 與傳統系統相容

對於大多數構建現代應用程式的.NET開發人員來說,IronPDF提供了一組強大的功能,易於使用和透明的定價。 其基於Chrome的渲染引擎保證了高保真的HTML到PDF轉換,而直觀的API加速了開發過程。

對於需要CAD轉換、複雜表單處理或使用過時文件格式的企業,PDFTron仍然可行。 然而,定價不透明和模塊化授權結構可能會顯著增加總成本。

入門

嘗試IronPDF:

探索PDFTron:

記得在做出決定之前,根據您的具體用例徹底評估這兩個選項。 考慮長期成本、支持質量、和功能規劃路線圖,以及技術能力。

現在開始使用IronPDF。
green arrow pointer

請注意PDFTron是其各自所有者的註冊商標。 此站點與PDFTron無關、未經其認可或贊助。 所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較僅供參考,反映撰寫時公開可用的資訊。

常見問題

如何在C#中將HTML轉換為PDF?

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

IronPDF與PDFTron在HTML轉PDF轉換上的效能差異有哪些?

IronPDF的Chrome引擎對於複雜的網頁內容提供了卓越的渲染能力,對JavaScript和CSS3的支持更好。而PDFTron雖然在簡單HTML上速度更快,但處理複雜內容可能不如IronPDF。

IronPDF和PDFTron有哪些授權選項?

IronPDF提供透明且永久的授權,所有功能均包含在內,起價為$749。而PDFTron則需要根據需求獲取自定義報價,價格範圍從每年$5,000到超過$100,000不等。

是否可以使用這些程式庫將ASPX頁面轉換為PDF?

是的,IronPDF可以透過AspxToPdf.RenderThisPageAsPdf方法將ASPX頁面轉換為PDF,僅需一行程式碼。PDFTron不直接支持ASPX頁面的轉換。

哪個程式庫更適合Azure等雲端環境?

IronPDF優化了雲端環境,包括Azure和AWS,並與Functions和WebApps無縫配合。PDFTron可能需要額外的配置以實現最佳的雲端部署。

IronPDF或PDFTron可以建立可填寫的PDF表單嗎?

是的,兩者皆支持建立可填寫的PDF表單。IronPDF使用CreatePdfFormsFromHtml進行HTML表單的自動轉換。PDFTron提供豐富的表單欄位型別,但需更複雜的整合。

IronPDF和PDFTron使用者有哪些支援選項?

IronPDF提供24/5工程師支援,直達開發者聯繫,典型的回應時間是24-48小時。PDFTron的支持選項取決於授權層級,提供基本的論壇支援和付費的直接協助。

IronPDF和PDFTron在處理密碼保護網站方面如何比較?

IronPDF透過ChromeHttpLoginCredentials支持驗證以處理登錄表單和HTTP驗證,而PDFTron在這方面的支持有限。

Jacob Mellor,首席技術官 @ Team Iron
首席技術官

Jacob Mellor是Iron Software的首席技術官,一位在C# PDF技術上開創先河的遠見工程師。作為Iron Software核心程式碼庫的原開發者,他從創立以來就一直在塑造公司的產品架構,與首席執行官Cameron Rimington一起將公司轉變為服務於NASA、特斯拉和全球政府公司的50多名人員的公司。

Jacob擁有曼徹斯特大學的土木工程一等榮譽學士學位(BEng),於1998-2001年之間獲得。在1999年於倫敦創辦他的第一家軟體公司並於2005年建立了他的第一批.NET元組件後,他專注於解決Microsoft生態系統中的複雜問題。

他的旗艦IronPDF和Iron Suite .NET程式庫在全球獲得了超過3000萬次NuGet安裝依據,他的基礎程式碼基繼續支援著世界各地開發者使用的工具。擁有25年的商業經驗和41年的程式設計專業知識,他仍專注於推動企業級C#、Java和Python PDF技術的創新,同時指導下一代技術領導者。

Iron 支援團隊

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