跳至页脚内容
产品比较

IronPDF 与 GemBox.Pdf:完整的 .NET PDF 库 HTML 到 PDF 转换比较指南

当开发需要PDF生成和操作的.NET应用程序时,选择合适的C# PDF库可以显著影响项目的成功。 这份综合对比分析了IronPDF和GemBox.Pdf这两个知名的.NET PDF库,帮助开发者根据功能、性能、价格和实际使用案例作出明智的决策。

快速比较概述

class="product__comprehensive-comparison-table">
class="table-container">
class="table-number">产品对比概述
class="table-title">IronPDF与GemBox.Pdf在.NET开发中的功能对比
类别 功能/方面 IronPDF GemBox.Pdf 主要优势
核心架构 设计哲学 以HTML为先, Chrome渲染 PDF原生操作 取决于上下文
API复杂性 简单方法如RenderHtmlAsPdf() 低层次PDF对象 IronPDF:更快的开发
学习曲线 通常1-2天 通常3-5天 IronPDF:更快的采用
平台支持 跨平台 Windows,Linux,macOS,Docker Windows,Linux,macOS,Android,iOS GemBox:支持移动设备
.NET版本 .NET 10, 9, 8, 7, 6, 5, Core 3.1+, Framework 4.6.2+ .NET 6, Standard 2.0, Framework 3.5+ IronPDF:最新的.NET支持
云平台 Azure/AWS优化 标准云支持 IronPDF:准备好云支持
HTML to PDF 渲染引擎 完整的Chrome V8引擎 无内置HTML支持* IronPDF:原生HTML到PDF
CSS3/HTML5支持 完全支持 需要GemBox.Document IronPDF:现代网页标准
JavaScript执行 完全支持JavaScript 不支持JavaScript IronPDF:动态内容
渲染速度 ~125ms典型 N/A(无HTML支持) IronPDF:快速渲染
开发者体验 代码示例 100+现成的示例 100+可用示例 两者:丰富的资源
文档 教程,如何操作,视频 聚焦于API文档 IronPDF:多元学习路径
内容操作 合并/拆分PDFs 内置方法 内置方法 两者:基本功能
文本提取 Unicode支持, OCR集成 Unicode支持, 内置OCR GemBox:内置OCR
表单支持 HTML表单到PDF表单 创建,填充,展平表单 取决于上下文
性能指标 内存使用量 通常低于10MB 低内存占用 两者:高效
线程支持 本地async/await优化 线程安全操作 IronPDF:更好的异步支持
安全与加密 加密级别 AES-256,自定义处理程序 AES-256标准 两者:行业标准
数字签名 集成,视觉签名 数字签名支持 两者:签名支持
许可与价格 入门级 Lite:$799(1开发者,1项目) 单一开发者:0(1开发者,无限项目) IronPDF:较低的入门成本
再分发 +,999免版税 包括,无限制部署 GemBox:更好的部署条款
套件选择 Iron Suite:$1,498(9个产品) GemBox套件:,200(7个产品) IronPDF:更高的套件价值
支持 支持包含 是的,24/5工程支持 是的,1年专业支持 两者:良好的支持
响应时间 通常24-48小时 在1个工作日内 两者:快速响应
最适合 用例 HTML到PDF,网页应用,报告 PDF操作,表单,OCR 取决于上下文
class="table-note"> 注. GemBox.Pdf专注于PDF操作,要求购买GemBox.Document进行HTML转换。IronPDF提供原生HTML到PDF转换,带有完整的浏览器渲染。*在GemBox中需要额外购买产品以支持HTML。

请注意GemBox.Pdf需要单独的GemBox.Document库($890额外收费)来进行HTML到PDF的转换.

什么是IronPDF库?

IronPDF作为一款全面的.NET PDF库脱颖而出,专为使HTML到PDF转换对于开发人员无缝进行而设计。 由Chrome渲染引擎为核心构建,IronPDF改变了开发人员在C#,F#和VB.NET应用程序中处理PDF生成的方式。

该库的哲学中心在于利用现有的网页开发技能。 开发人员可以使用熟悉的HTML、CSS和JavaScript来创建复杂的PDF文档,而不是学习复杂的PDF API。 这种方法大大缩短了开发时间,同时确保像素级别匹配现代网页标准的渲染。

IronPDF的核心功能

IronPDF提供了广泛的功能集,涵盖了开发人员可能遇到的几乎所有PDF相关任务:

HTML到PDF转换的卓越性

  • Chrome V8引擎:使用与Google Chrome相同的引擎渲染HTML,确保98%以上的浏览器一致性
  • 全面的CSS3/HTML5支持:完整支持现代网页标准,包括flexbox,grid和动画
  • JavaScript执行:在渲染前处理JavaScript,完美捕获动态内容
  • 响应式设计:通过可定制的视口设置处理响应式布局
  • 网页字体支持:精确呈现Google字体,自定义字体和图标字体

高级PDF操作

安全和合规

  • 加密:使用自定义权限设置的AES-256加密
  • PDF/A合规性:生成适合长期存储的归档质量PDF
  • 内容删除:永久删除敏感内容
  • 密码保护:支持用户和所有者密码,具有细致的权限

IronPDF代码示例:带高级功能的HTML到PDF

using IronPdf;
using IronPdf.Rendering;

// Configure the Chrome renderer with advanced options
var renderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        // Set paper orientation and size
        PaperOrientation = PdfPaperOrientation.Portrait,
        PaperSize = PdfPaperSize.A4,

        // Configure margins (in millimeters)
        MarginTop = 25,
        MarginBottom = 25,
        MarginLeft = 20,
        MarginRight = 20,

        // Enable JavaScript execution
        EnableJavaScript = true,
        RenderDelay = 1000, // Wait 1 second for JS to complete

        // Print background colors and images
        PrintHtmlBackgrounds = true,

        // Create PDF forms from HTML form elements
        CreatePdfFormsFromHtml = true,

        // Custom header and footer
        HtmlHeader = new HtmlHeaderFooter
        {
            Height = 20,
            HtmlFragment = "<div style='text-align: center; font-size: 12px;'>Company Report - {page} of {total-pages}</div>",
            DrawDividerLine = true
        },

        HtmlFooter = new HtmlHeaderFooter
        {
            Height = 15,
            HtmlFragment = "<div style='text-align: center; font-size: 10px;'>© 2025 Company Name. Confidential.</div>"
        }
    }
};

// Convert complex HTML with CSS and JavaScript
string htmlContent = @"
<!DOCTYPE html>
<html>
<head>
    <style>
        body { font-family: 'Segoe UI', Arial, sans-serif; line-height: 1.6; }
        .invoice-header { 
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            border-radius: 10px;
            margin-bottom: 30px;
        }
        .data-table { 
            width: 100%; 
            border-collapse: collapse; 
            margin-top: 20px;
        }
        .data-table th { 
            background-color: #f8f9fa; 
            padding: 12px; 
            text-align: left;
            border-bottom: 2px solid #dee2e6;
        }
        .data-table td { 
            padding: 10px; 
            border-bottom: 1px solid #dee2e6;
        }
        .total-section {
            margin-top: 30px;
            text-align: right;
            font-size: 18px;
            font-weight: bold;
        }
        @media print {
            .no-print { display: none; }
        }
    </style>
</head>
<body>
    <div class='invoice-header'>
        <h1>Invoice #INV-2025-001</h1>
        <p>Date: <span id='current-date'></span></p>
    </div>

    <table class='data-table'>
        <thead>
            <tr>
                <th>Item Description</th>
                <th>Quantity</th>
                <th>Unit Price</th>
                <th>Total</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Professional PDF Library License</td>
                <td>1</td>
                <td>$799.00</td>
                <td>$799.00</td>
            </tr>
            <tr>
                <td>Priority Support (1 Year)</td>
                <td>1</td>
                <td>$299.00</td>
                <td>$299.00</td>
            </tr>
        </tbody>
    </table>

    <div class='total-section'>
        <p>Subtotal: $1,048.00</p>
        <p>Tax (8%): $83.84</p>
        <p style='color: #667eea; font-size: 24px;'>Total: $1,131.84</p>
    </div>

    <script>
        // Dynamic date insertion
        document.getElementById('current-date').textContent = new Date().toLocaleDateString('en-US', {
            year: 'numeric',
            month: 'long',
            day: 'numeric'
        });
    </script>
</body>
</html>";

// Render the HTML to PDF
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);

// Apply additional security settings
pdf.SecuritySettings.OwnerPassword = "admin123";
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserFormData = true;

// Add metadata
pdf.MetaData.Author = "Invoice System";
pdf.MetaData.Title = "Invoice INV-2025-001";
pdf.MetaData.Subject = "Customer Invoice";
pdf.MetaData.Keywords = "invoice, payment, 2025";
pdf.MetaData.CreationDate = DateTime.Now;

// Save the PDF
pdf.SaveAs("invoice-2025-001.pdf");

// Optional: Save as PDF/A for archival
pdf.SaveAsPdfA("invoice-2025-001-archive.pdf", PdfAVersions.PdfA3);
using IronPdf;
using IronPdf.Rendering;

// Configure the Chrome renderer with advanced options
var renderer = new ChromePdfRenderer
{
    RenderingOptions = new ChromePdfRenderOptions
    {
        // Set paper orientation and size
        PaperOrientation = PdfPaperOrientation.Portrait,
        PaperSize = PdfPaperSize.A4,

        // Configure margins (in millimeters)
        MarginTop = 25,
        MarginBottom = 25,
        MarginLeft = 20,
        MarginRight = 20,

        // Enable JavaScript execution
        EnableJavaScript = true,
        RenderDelay = 1000, // Wait 1 second for JS to complete

        // Print background colors and images
        PrintHtmlBackgrounds = true,

        // Create PDF forms from HTML form elements
        CreatePdfFormsFromHtml = true,

        // Custom header and footer
        HtmlHeader = new HtmlHeaderFooter
        {
            Height = 20,
            HtmlFragment = "<div style='text-align: center; font-size: 12px;'>Company Report - {page} of {total-pages}</div>",
            DrawDividerLine = true
        },

        HtmlFooter = new HtmlHeaderFooter
        {
            Height = 15,
            HtmlFragment = "<div style='text-align: center; font-size: 10px;'>© 2025 Company Name. Confidential.</div>"
        }
    }
};

// Convert complex HTML with CSS and JavaScript
string htmlContent = @"
<!DOCTYPE html>
<html>
<head>
    <style>
        body { font-family: 'Segoe UI', Arial, sans-serif; line-height: 1.6; }
        .invoice-header { 
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            border-radius: 10px;
            margin-bottom: 30px;
        }
        .data-table { 
            width: 100%; 
            border-collapse: collapse; 
            margin-top: 20px;
        }
        .data-table th { 
            background-color: #f8f9fa; 
            padding: 12px; 
            text-align: left;
            border-bottom: 2px solid #dee2e6;
        }
        .data-table td { 
            padding: 10px; 
            border-bottom: 1px solid #dee2e6;
        }
        .total-section {
            margin-top: 30px;
            text-align: right;
            font-size: 18px;
            font-weight: bold;
        }
        @media print {
            .no-print { display: none; }
        }
    </style>
</head>
<body>
    <div class='invoice-header'>
        <h1>Invoice #INV-2025-001</h1>
        <p>Date: <span id='current-date'></span></p>
    </div>

    <table class='data-table'>
        <thead>
            <tr>
                <th>Item Description</th>
                <th>Quantity</th>
                <th>Unit Price</th>
                <th>Total</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Professional PDF Library License</td>
                <td>1</td>
                <td>$799.00</td>
                <td>$799.00</td>
            </tr>
            <tr>
                <td>Priority Support (1 Year)</td>
                <td>1</td>
                <td>$299.00</td>
                <td>$299.00</td>
            </tr>
        </tbody>
    </table>

    <div class='total-section'>
        <p>Subtotal: $1,048.00</p>
        <p>Tax (8%): $83.84</p>
        <p style='color: #667eea; font-size: 24px;'>Total: $1,131.84</p>
    </div>

    <script>
        // Dynamic date insertion
        document.getElementById('current-date').textContent = new Date().toLocaleDateString('en-US', {
            year: 'numeric',
            month: 'long',
            day: 'numeric'
        });
    </script>
</body>
</html>";

// Render the HTML to PDF
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);

// Apply additional security settings
pdf.SecuritySettings.OwnerPassword = "admin123";
pdf.SecuritySettings.UserPassword = "user123";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserFormData = true;

// Add metadata
pdf.MetaData.Author = "Invoice System";
pdf.MetaData.Title = "Invoice INV-2025-001";
pdf.MetaData.Subject = "Customer Invoice";
pdf.MetaData.Keywords = "invoice, payment, 2025";
pdf.MetaData.CreationDate = DateTime.Now;

// Save the PDF
pdf.SaveAs("invoice-2025-001.pdf");

// Optional: Save as PDF/A for archival
pdf.SaveAsPdfA("invoice-2025-001-archive.pdf", PdfAVersions.PdfA3);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

此示例展示了IronPDF处理包含渐变、表格、动态JavaScript内容和高级PDF功能(如安全设置和元数据)的复杂HTML布局的能力。 库无缝处理一切,生成的专业PDF与HTML设计完全一致。

什么是GemBox.Pdf库?

GemBox.Pdf代表了一种不同的.NET中PDF操作方法。 与其专注于HTML到PDF转换,GemBox.Pdf专注于低层次的PDF操作和直接的PDF操控。 这使得它特别适用于开发人员需要精确控制PDF结构和内容的场景。

该库在处理现有PDF文档方面表现出色,提供了强大的功能来阅读、编辑和以细粒度水平操控PDF文件。 GemBox.Pdf无需依赖于Adobe Acrobat,在各种环境下的部署变得简单。

GemBox.Pdf的核心功能

GemBox.Pdf提供全面的PDF操作功能:

PDF文档操作

  • 读取和写入PDF:直接访问PDF结构和内容
  • 合并和拆分:合并多个PDF或提取特定页面
  • 克隆页面:在不同的PDF文档之间导入页面
  • 页面管理:以编程方式添加、移除或重新排序页面

内容提取和操控

  • 文本提取:提取带定位信息的Unicode文本
  • 图像提取:从PDF文档中检索嵌入的图像
  • OCR支持:内置的光学字符识别用于扫描文档
  • 内容删除:永久移除敏感信息

表单和交互

  • 互动表单:创建、填写、展平和导出PDF表单
  • 表单字段管理:以编程方式访问所有表单字段类型
  • 注释:添加超链接和其他PDF注释

图形和视觉元素

  • 绘图操作:添加文本、图像和矢量图形
  • 形状和路径:创建复杂的矢量绘图
  • 水印:应用文本和图像水印
  • 内容组:将内容组织成逻辑组

GemBox.Pdf代码示例:PDF操作和表单

using GemBox.Pdf;
using GemBox.Pdf.Content;
using GemBox.Pdf.Forms;
using GemBox.Pdf.Security;

// Set license (use FREE-LIMITED-KEY for evaluation)
ComponentInfo.SetLicense("FREE-LIMITED-KEY");

// Create a new PDF document from scratch
using (var document = new PdfDocument())
{
    // Add a page with custom size
    var page = document.Pages.Add();

    // Create formatted text with multiple styles
    using (var formattedText = new PdfFormattedText())
    {
        formattedText.FontSize = 24;
        formattedText.FontFamily = new PdfFontFamily("Arial");
        formattedText.Color = PdfColor.FromRgb(0.2, 0.2, 0.6);
        formattedText.AppendLine("GemBox.Pdf Document Example");

        formattedText.FontSize = 12;
        formattedText.Color = PdfColor.FromRgb(0, 0, 0);
        formattedText.AppendLine("This document demonstrates PDF creation and manipulation features.");

        // Draw text to the page
        page.Content.DrawText(formattedText, new PdfPoint(50, 700));
    }

    // Add a form to the document
    var form = document.Form;

    // Create text field
    var textField = form.Fields.AddText(page, 50, 600, 200, 30);
    textField.Name = "CustomerName";
    textField.Value = "Enter your name";
    textField.Format.Fill.Color = PdfColor.FromRgb(0.95, 0.95, 0.95);

    // Create checkbox
    var checkBox = form.Fields.AddCheck(page, 50, 550, 20, 20);
    checkBox.Name = "Agreement";
    checkBox.Checked = false;

    // Add descriptive text next to checkbox
    using (var checkboxLabel = new PdfFormattedText())
    {
        checkboxLabel.Append("I agree to the terms and conditions");
        page.Content.DrawText(checkboxLabel, new PdfPoint(80, 555));
    }

    // Create submit button
    var submitButton = form.Fields.AddButton(page, 50, 500, 100, 30);
    submitButton.Name = "Submit";
    submitButton.Actions.Activate = PdfActionType.Named;

    // Add button appearance
    using (var buttonText = new PdfFormattedText())
    {
        buttonText.Append("Submit Form");
        buttonText.FontSize = 14;
        buttonText.Color = PdfColor.FromRgb(1, 1, 1);

        // Create button appearance stream
        var appearance = submitButton.Appearance.Normal;
        appearance.Fill.Color = PdfColor.FromRgb(0.2, 0.4, 0.8);
        appearance.Stroke.Color = PdfColor.FromRgb(0.1, 0.2, 0.4);
        appearance.Stroke.Width = 1;

        // Draw button background
        appearance.DrawRectangle(new PdfPoint(0, 0), new PdfSize(100, 30), true, true);

        // Draw button text
        appearance.DrawText(buttonText, new PdfPoint(20, 10));
    }

    // Add a table using low-level graphics
    var tableTop = 400;
    var tableLeft = 50;
    var cellWidth = 150;
    var cellHeight = 30;

    // Draw table headers
    page.Content.DrawRectangle(new PdfPoint(tableLeft, tableTop), 
        new PdfSize(cellWidth * 3, cellHeight), true, true);

    using (var headerText = new PdfFormattedText())
    {
        headerText.FontSize = 12;
        headerText.Color = PdfColor.FromRgb(1, 1, 1);
        headerText.Append("Product");
        page.Content.DrawText(headerText, new PdfPoint(tableLeft + 10, tableTop + 10));

        headerText.Clear();
        headerText.Append("Quantity");
        page.Content.DrawText(headerText, new PdfPoint(tableLeft + cellWidth + 10, tableTop + 10));

        headerText.Clear();
        headerText.Append("Price");
        page.Content.DrawText(headerText, new PdfPoint(tableLeft + cellWidth * 2 + 10, tableTop + 10));
    }

    // Draw table data rows
    var rowData = new[]
    {
        new { Product = "PDF Library", Quantity = "1", Price = "$890" },
        new { Product = "Support Plan", Quantity = "1", Price = "$299" },
        new { Product = "Training", Quantity = "2", Price = "$500" }
    };

    var currentY = tableTop - cellHeight;
    foreach (var row in rowData)
    {
        // Draw cell borders
        page.Content.DrawRectangle(new PdfPoint(tableLeft, currentY), 
            new PdfSize(cellWidth, cellHeight), false, true);
        page.Content.DrawRectangle(new PdfPoint(tableLeft + cellWidth, currentY), 
            new PdfSize(cellWidth, cellHeight), false, true);
        page.Content.DrawRectangle(new PdfPoint(tableLeft + cellWidth * 2, currentY), 
            new PdfSize(cellWidth, cellHeight), false, true);

        // Draw cell content
        using (var cellText = new PdfFormattedText())
        {
            cellText.FontSize = 11;
            cellText.Append(row.Product);
            page.Content.DrawText(cellText, new PdfPoint(tableLeft + 10, currentY + 10));

            cellText.Clear();
            cellText.Append(row.Quantity);
            page.Content.DrawText(cellText, new PdfPoint(tableLeft + cellWidth + 10, currentY + 10));

            cellText.Clear();
            cellText.Append(row.Price);
            page.Content.DrawText(cellText, new PdfPoint(tableLeft + cellWidth * 2 + 10, currentY + 10));
        }

        currentY -= cellHeight;
    }

    // Apply security settings
    var securitySettings = document.SecuritySettings;
    securitySettings.DocumentOpenPassword = "user123";
    securitySettings.PermissionsPassword = "owner123";
    securitySettings.Permissions = PdfPermissions.AllowPrint | PdfPermissions.AllowFormFill;

    // Save the document
    document.Save("gembox-example.pdf");
}

// Example: Manipulating existing PDF
using (var existingDoc = PdfDocument.Load("existing-document.pdf"))
{
    // Extract text from first page
    var page = existingDoc.Pages[0];
    var text = page.Content.GetText();
    Console.WriteLine($"Extracted text: {text}");

    // Add watermark to all pages
    foreach (var p in existingDoc.Pages)
    {
        using (var watermark = new PdfFormattedText())
        {
            watermark.Append("CONFIDENTIAL");
            watermark.FontSize = 50;
            watermark.Color = PdfColor.FromRgb(0.5, 0.5, 0.5);
            watermark.Opacity = 0.3;

            // Calculate center position
            var pageWidth = p.MediaBox.Width;
            var pageHeight = p.MediaBox.Height;
            var textWidth = watermark.Width;
            var textHeight = watermark.Height;

            var x = (pageWidth - textWidth) / 2;
            var y = (pageHeight - textHeight) / 2;

            // Draw watermark diagonally
            p.Content.SaveGraphicsState();
            p.Content.SetTransform(1, 0, 0, 1, x, y);
            p.Content.SetTransform(0.7071, 0.7071, -0.7071, 0.7071, 0, 0);
            p.Content.DrawText(watermark, new PdfPoint(0, 0));
            p.Content.RestoreGraphicsState();
        }
    }

    existingDoc.Save("watermarked-document.pdf");
}
using GemBox.Pdf;
using GemBox.Pdf.Content;
using GemBox.Pdf.Forms;
using GemBox.Pdf.Security;

// Set license (use FREE-LIMITED-KEY for evaluation)
ComponentInfo.SetLicense("FREE-LIMITED-KEY");

// Create a new PDF document from scratch
using (var document = new PdfDocument())
{
    // Add a page with custom size
    var page = document.Pages.Add();

    // Create formatted text with multiple styles
    using (var formattedText = new PdfFormattedText())
    {
        formattedText.FontSize = 24;
        formattedText.FontFamily = new PdfFontFamily("Arial");
        formattedText.Color = PdfColor.FromRgb(0.2, 0.2, 0.6);
        formattedText.AppendLine("GemBox.Pdf Document Example");

        formattedText.FontSize = 12;
        formattedText.Color = PdfColor.FromRgb(0, 0, 0);
        formattedText.AppendLine("This document demonstrates PDF creation and manipulation features.");

        // Draw text to the page
        page.Content.DrawText(formattedText, new PdfPoint(50, 700));
    }

    // Add a form to the document
    var form = document.Form;

    // Create text field
    var textField = form.Fields.AddText(page, 50, 600, 200, 30);
    textField.Name = "CustomerName";
    textField.Value = "Enter your name";
    textField.Format.Fill.Color = PdfColor.FromRgb(0.95, 0.95, 0.95);

    // Create checkbox
    var checkBox = form.Fields.AddCheck(page, 50, 550, 20, 20);
    checkBox.Name = "Agreement";
    checkBox.Checked = false;

    // Add descriptive text next to checkbox
    using (var checkboxLabel = new PdfFormattedText())
    {
        checkboxLabel.Append("I agree to the terms and conditions");
        page.Content.DrawText(checkboxLabel, new PdfPoint(80, 555));
    }

    // Create submit button
    var submitButton = form.Fields.AddButton(page, 50, 500, 100, 30);
    submitButton.Name = "Submit";
    submitButton.Actions.Activate = PdfActionType.Named;

    // Add button appearance
    using (var buttonText = new PdfFormattedText())
    {
        buttonText.Append("Submit Form");
        buttonText.FontSize = 14;
        buttonText.Color = PdfColor.FromRgb(1, 1, 1);

        // Create button appearance stream
        var appearance = submitButton.Appearance.Normal;
        appearance.Fill.Color = PdfColor.FromRgb(0.2, 0.4, 0.8);
        appearance.Stroke.Color = PdfColor.FromRgb(0.1, 0.2, 0.4);
        appearance.Stroke.Width = 1;

        // Draw button background
        appearance.DrawRectangle(new PdfPoint(0, 0), new PdfSize(100, 30), true, true);

        // Draw button text
        appearance.DrawText(buttonText, new PdfPoint(20, 10));
    }

    // Add a table using low-level graphics
    var tableTop = 400;
    var tableLeft = 50;
    var cellWidth = 150;
    var cellHeight = 30;

    // Draw table headers
    page.Content.DrawRectangle(new PdfPoint(tableLeft, tableTop), 
        new PdfSize(cellWidth * 3, cellHeight), true, true);

    using (var headerText = new PdfFormattedText())
    {
        headerText.FontSize = 12;
        headerText.Color = PdfColor.FromRgb(1, 1, 1);
        headerText.Append("Product");
        page.Content.DrawText(headerText, new PdfPoint(tableLeft + 10, tableTop + 10));

        headerText.Clear();
        headerText.Append("Quantity");
        page.Content.DrawText(headerText, new PdfPoint(tableLeft + cellWidth + 10, tableTop + 10));

        headerText.Clear();
        headerText.Append("Price");
        page.Content.DrawText(headerText, new PdfPoint(tableLeft + cellWidth * 2 + 10, tableTop + 10));
    }

    // Draw table data rows
    var rowData = new[]
    {
        new { Product = "PDF Library", Quantity = "1", Price = "$890" },
        new { Product = "Support Plan", Quantity = "1", Price = "$299" },
        new { Product = "Training", Quantity = "2", Price = "$500" }
    };

    var currentY = tableTop - cellHeight;
    foreach (var row in rowData)
    {
        // Draw cell borders
        page.Content.DrawRectangle(new PdfPoint(tableLeft, currentY), 
            new PdfSize(cellWidth, cellHeight), false, true);
        page.Content.DrawRectangle(new PdfPoint(tableLeft + cellWidth, currentY), 
            new PdfSize(cellWidth, cellHeight), false, true);
        page.Content.DrawRectangle(new PdfPoint(tableLeft + cellWidth * 2, currentY), 
            new PdfSize(cellWidth, cellHeight), false, true);

        // Draw cell content
        using (var cellText = new PdfFormattedText())
        {
            cellText.FontSize = 11;
            cellText.Append(row.Product);
            page.Content.DrawText(cellText, new PdfPoint(tableLeft + 10, currentY + 10));

            cellText.Clear();
            cellText.Append(row.Quantity);
            page.Content.DrawText(cellText, new PdfPoint(tableLeft + cellWidth + 10, currentY + 10));

            cellText.Clear();
            cellText.Append(row.Price);
            page.Content.DrawText(cellText, new PdfPoint(tableLeft + cellWidth * 2 + 10, currentY + 10));
        }

        currentY -= cellHeight;
    }

    // Apply security settings
    var securitySettings = document.SecuritySettings;
    securitySettings.DocumentOpenPassword = "user123";
    securitySettings.PermissionsPassword = "owner123";
    securitySettings.Permissions = PdfPermissions.AllowPrint | PdfPermissions.AllowFormFill;

    // Save the document
    document.Save("gembox-example.pdf");
}

// Example: Manipulating existing PDF
using (var existingDoc = PdfDocument.Load("existing-document.pdf"))
{
    // Extract text from first page
    var page = existingDoc.Pages[0];
    var text = page.Content.GetText();
    Console.WriteLine($"Extracted text: {text}");

    // Add watermark to all pages
    foreach (var p in existingDoc.Pages)
    {
        using (var watermark = new PdfFormattedText())
        {
            watermark.Append("CONFIDENTIAL");
            watermark.FontSize = 50;
            watermark.Color = PdfColor.FromRgb(0.5, 0.5, 0.5);
            watermark.Opacity = 0.3;

            // Calculate center position
            var pageWidth = p.MediaBox.Width;
            var pageHeight = p.MediaBox.Height;
            var textWidth = watermark.Width;
            var textHeight = watermark.Height;

            var x = (pageWidth - textWidth) / 2;
            var y = (pageHeight - textHeight) / 2;

            // Draw watermark diagonally
            p.Content.SaveGraphicsState();
            p.Content.SetTransform(1, 0, 0, 1, x, y);
            p.Content.SetTransform(0.7071, 0.7071, -0.7071, 0.7071, 0, 0);
            p.Content.DrawText(watermark, new PdfPoint(0, 0));
            p.Content.RestoreGraphicsState();
        }
    }

    existingDoc.Save("watermarked-document.pdf");
}
Imports GemBox.Pdf
Imports GemBox.Pdf.Content
Imports GemBox.Pdf.Forms
Imports GemBox.Pdf.Security

' Set license (use FREE-LIMITED-KEY for evaluation)
ComponentInfo.SetLicense("FREE-LIMITED-KEY")

' Create a new PDF document from scratch
Using document = New PdfDocument()
	' Add a page with custom size
	Dim page = document.Pages.Add()

	' Create formatted text with multiple styles
	Using formattedText = New PdfFormattedText()
		formattedText.FontSize = 24
		formattedText.FontFamily = New PdfFontFamily("Arial")
		formattedText.Color = PdfColor.FromRgb(0.2, 0.2, 0.6)
		formattedText.AppendLine("GemBox.Pdf Document Example")

		formattedText.FontSize = 12
		formattedText.Color = PdfColor.FromRgb(0, 0, 0)
		formattedText.AppendLine("This document demonstrates PDF creation and manipulation features.")

		' Draw text to the page
		page.Content.DrawText(formattedText, New PdfPoint(50, 700))
	End Using

	' Add a form to the document
	Dim form = document.Form

	' Create text field
	Dim textField = form.Fields.AddText(page, 50, 600, 200, 30)
	textField.Name = "CustomerName"
	textField.Value = "Enter your name"
	textField.Format.Fill.Color = PdfColor.FromRgb(0.95, 0.95, 0.95)

	' Create checkbox
	Dim checkBox = form.Fields.AddCheck(page, 50, 550, 20, 20)
	checkBox.Name = "Agreement"
	checkBox.Checked = False

	' Add descriptive text next to checkbox
	Using checkboxLabel = New PdfFormattedText()
		checkboxLabel.Append("I agree to the terms and conditions")
		page.Content.DrawText(checkboxLabel, New PdfPoint(80, 555))
	End Using

	' Create submit button
	Dim submitButton = form.Fields.AddButton(page, 50, 500, 100, 30)
	submitButton.Name = "Submit"
	submitButton.Actions.Activate = PdfActionType.Named

	' Add button appearance
	Using buttonText = New PdfFormattedText()
		buttonText.Append("Submit Form")
		buttonText.FontSize = 14
		buttonText.Color = PdfColor.FromRgb(1, 1, 1)

		' Create button appearance stream
		Dim appearance = submitButton.Appearance.Normal
		appearance.Fill.Color = PdfColor.FromRgb(0.2, 0.4, 0.8)
		appearance.Stroke.Color = PdfColor.FromRgb(0.1, 0.2, 0.4)
		appearance.Stroke.Width = 1

		' Draw button background
		appearance.DrawRectangle(New PdfPoint(0, 0), New PdfSize(100, 30), True, True)

		' Draw button text
		appearance.DrawText(buttonText, New PdfPoint(20, 10))
	End Using

	' Add a table using low-level graphics
	Dim tableTop = 400
	Dim tableLeft = 50
	Dim cellWidth = 150
	Dim cellHeight = 30

	' Draw table headers
	page.Content.DrawRectangle(New PdfPoint(tableLeft, tableTop), New PdfSize(cellWidth * 3, cellHeight), True, True)

	Using headerText = New PdfFormattedText()
		headerText.FontSize = 12
		headerText.Color = PdfColor.FromRgb(1, 1, 1)
		headerText.Append("Product")
		page.Content.DrawText(headerText, New PdfPoint(tableLeft + 10, tableTop + 10))

		headerText.Clear()
		headerText.Append("Quantity")
		page.Content.DrawText(headerText, New PdfPoint(tableLeft + cellWidth + 10, tableTop + 10))

		headerText.Clear()
		headerText.Append("Price")
		page.Content.DrawText(headerText, New PdfPoint(tableLeft + cellWidth * 2 + 10, tableTop + 10))
	End Using

	' Draw table data rows
	Dim rowData = {
		New With {
			Key .Product = "PDF Library",
			Key .Quantity = "1",
			Key .Price = "$890"
		},
		New With {
			Key .Product = "Support Plan",
			Key .Quantity = "1",
			Key .Price = "$299"
		},
		New With {
			Key .Product = "Training",
			Key .Quantity = "2",
			Key .Price = "$500"
		}
	}

	Dim currentY = tableTop - cellHeight
	For Each row In rowData
		' Draw cell borders
		page.Content.DrawRectangle(New PdfPoint(tableLeft, currentY), New PdfSize(cellWidth, cellHeight), False, True)
		page.Content.DrawRectangle(New PdfPoint(tableLeft + cellWidth, currentY), New PdfSize(cellWidth, cellHeight), False, True)
		page.Content.DrawRectangle(New PdfPoint(tableLeft + cellWidth * 2, currentY), New PdfSize(cellWidth, cellHeight), False, True)

		' Draw cell content
		Using cellText = New PdfFormattedText()
			cellText.FontSize = 11
			cellText.Append(row.Product)
			page.Content.DrawText(cellText, New PdfPoint(tableLeft + 10, currentY + 10))

			cellText.Clear()
			cellText.Append(row.Quantity)
			page.Content.DrawText(cellText, New PdfPoint(tableLeft + cellWidth + 10, currentY + 10))

			cellText.Clear()
			cellText.Append(row.Price)
			page.Content.DrawText(cellText, New PdfPoint(tableLeft + cellWidth * 2 + 10, currentY + 10))
		End Using

		currentY -= cellHeight
	Next row

	' Apply security settings
	Dim securitySettings = document.SecuritySettings
	securitySettings.DocumentOpenPassword = "user123"
	securitySettings.PermissionsPassword = "owner123"
	securitySettings.Permissions = PdfPermissions.AllowPrint Or PdfPermissions.AllowFormFill

	' Save the document
	document.Save("gembox-example.pdf")
End Using

' Example: Manipulating existing PDF
Using existingDoc = PdfDocument.Load("existing-document.pdf")
	' Extract text from first page
	Dim page = existingDoc.Pages(0)
	Dim text = page.Content.GetText()
	Console.WriteLine($"Extracted text: {text}")

	' Add watermark to all pages
	For Each p In existingDoc.Pages
		Using watermark = New PdfFormattedText()
			watermark.Append("CONFIDENTIAL")
			watermark.FontSize = 50
			watermark.Color = PdfColor.FromRgb(0.5, 0.5, 0.5)
			watermark.Opacity = 0.3

			' Calculate center position
			Dim pageWidth = p.MediaBox.Width
			Dim pageHeight = p.MediaBox.Height
			Dim textWidth = watermark.Width
			Dim textHeight = watermark.Height

			Dim x = (pageWidth - textWidth) \ 2
			Dim y = (pageHeight - textHeight) \ 2

			' Draw watermark diagonally
			p.Content.SaveGraphicsState()
			p.Content.SetTransform(1, 0, 0, 1, x, y)
			p.Content.SetTransform(0.7071, 0.7071, -0.7071, 0.7071, 0, 0)
			p.Content.DrawText(watermark, New PdfPoint(0, 0))
			p.Content.RestoreGraphicsState()
		End Using
	Next p

	existingDoc.Save("watermarked-document.pdf")
End Using
$vbLabelText   $csharpLabel

这个例子展示了GemBox.Pdf在低层次PDF操作中的优势,展示了表单创建、图形绘制和文档安全功能。 虽然代码比IronPDF的HTML方法更详尽,但它提供了对PDF各个方面的精确控制。

这些库如何处理 HTML 到 PDF 的转换? HTML到PDF转换的方法代表了IronPDF和GemBox.Pdf之间最显著的差异之一。 ### IronPDF的HTML到PDF方法 IronPDF是从头开始构建的,HTML到PDF转换是其主要重点。 该库包含一个完整的Chrome渲染引擎,它可以像网页浏览器一样精确处理HTML、CSS和JavaScript。 这意味着: - **真正的浏览器渲染**:使用与Google Chrome相同的Blink引擎 - **完整的网页标准**:全面支持CSS3,HTML5,flexbox,grid和现代JavaScript - **动态内容**:在渲染前执行JavaScript,捕获AJAX内容和动态元素 - **响应式设计**:处理媒体查询和响应式布局 - **外部资源**:自动从URL获取图像、样式表和字体 ### GemBox对HTML支持的局限 GemBox.Pdf自身**不支持HTML到PDF的转换**。 要用GemBox将HTML转换为PDF,开发人员必须: 1. 分别购买GemBox.Document(额外$890成本) 2. 使用GemBox.Document将HTML转换为DOCX 3. 然后将DOCX转换为PDF 这种方法有显著的限制: - **不支持JavaScript**:无法处理动态内容 - **有限的CSS支持**:许多现代CSS特性不受支持 - **样式问题**:已知在边框和复杂布局上有问题,如[Stack Overflow讨论](https://stackoverflow.com/questions/53113688/gembox-document-convert-html-to-pdf-border-css-does-not-work)中所述 - **仅为打印优化**:需要特定格式的HTML供打印使用 - **额外成本**:需要购买两个独立的库 ## 现代CSS框架支持:关键差异 当使用现代CSS框架如Bootstrap、Tailwind CSS和Foundation时,IronPDF基于Chrome的渲染的最大优势显而易见。 这些框架已成为现代Web应用程序的主干,其在PDF中正确渲染的能力对许多用例至关重要。 ### IronPDF:完整的现代框架支持 IronPDF的Chrome渲染引擎提供了对所有现代CSS框架的完整、原生支持: - **Bootstrap 5**:对响应式布局的全flexbox和CSS Grid支持 - **Tailwind CSS**:完整的实用程序优先CSS框架支持 - **Real-world examples**: Renders the [Bootstrap homepage](https://getbootstrap.com/) and [Bootstrap templates](https://getbootstrap.com/docs/5.3/examples/) pixel-perfect - **现代CSS3功能**:动画、变换、过渡、CSS自定义属性 - **响应式设计**:媒体查询和基于视口的布局无缝工作 **示例代码:Bootstrap表单到PDF** ```csharp using IronPdf; var renderer = new ChromePdfRenderer(); string bootstrapForm = @"

Customer Registration

"; var pdf = renderer.RenderHtmlAsPdf(bootstrapForm); pdf.SaveAs("bootstrap-form.pdf"); ``` ### GemBox:无现代框架支持 由于GemBox.Pdf缺乏原生HTML渲染,而且必须依赖于GemBox.Document来进行HTML转换,因此现代CSS框架面临重大限制: - **不支持Bootstrap**:Flexbox和CSS Grid特性无法正确渲染 - **不支持Tailwind CSS**:实用程序类和现代布局不支持 - **需要手动解决方案**:必须创建经过打印优化的HTML版本 - **有限的CSS3**:许多现代CSS特性无法使用 - **额外复杂性**:两步转换过程(HTML → DOCX → PDF)引入不一致性 根据[开发者讨论](https://stackoverflow.com/questions/53113688/gembox-document-convert-html-to-pdf-border-css-does-not-work),即使像边框和布局这样的基本CSS功能在GemBox的HTML转换方法中也可能有问题。 **现实世界的影响**:如果你的应用程序使用Bootstrap进行UI设计,并且你需要生成符合你的网络界面的PDF报告或导出,IronPDF提供了一个简单的解决方案,而使用GemBox则需要进行重大重新设计或人工作方案。 有关 CSS 框架兼容性的更多详情,请参阅 [Bootstrap & Flexbox CSS 指南](/troubleshooting/bootstrap-flex-css/)。 ## 哪个库在不同的PDF任务中表现出色? 了解每个库的优点有助于开发人员根据其具体需求选择合适的工具。 ### IronPDF表现出色的地方 IronPDF在以下场景中表现卓越: #### 1. **Web应用程序PDF生成** 非常适合SaaS应用程序、Web门户以及任何需要将Web内容转换为PDF的系统。 Chrome渲染引擎确保了复杂的Web布局,包括使用Bootstrap、Tailwind CSS或自定义框架的布局能完美呈现。 #### 2. **动态报告生成** 当报告包含图表(Chart.js, D3.js)、动态数据可视化或JavaScript渲染的内容时,IronPDF能准确捕获一切。 这使其成为商业智能仪表板和数据驱动应用程序的理想选择。 #### 3. **发票和文档模板** 使用HTML/CSS模板用于发票、收据和商业文档,允许设计师在不学习特定的PDF API的情况下创建模板。可以通过熟悉的网页技术快速进行更改。 #### 4. **快速开发项目** 简单的API和基于HTML的方法大大缩短了开发时间。开发人员可以在分钟内而不是小时内创建复杂的PDF。 #### 5. **跨平台部署** IronPDF原生支持Windows、Linux、macOS、Docker和云平台,简化了在各种环境下的部署。 ### GemBox.Pdf表现出色的地方 GemBox.Pdf在以下领域展示了它的优势: #### 1. **低层次PDF操作** 当需要对PDF结构进行精确控制时,GemBox.Pdf的面向对象的方法提供了对PDF元素、流和字典的直接访问。 #### 2. **重表单应用程序** 对于大量使用PDF表单的应用程序,GemBox.Pdf提供了全面的表单字段操作,包括以编程方式创建复杂的交互表单。 #### 3. **OCR需求** 凭借内置的OCR功能,GemBox.Pdf能够从扫描文档中提取文本,而无需额外的库,适用于文档数字化项目。 #### 4. **移动开发** 原生对Android和iOS平台的支持使得GemBox.Pdf成为需要PDF功能的移动应用程序的不错选择。 #### 5. **现有PDF的修改** 当主要工作是处理现有PDF而不是生成新的PDF时,GemBox.Pdf的提取、操作和修改工具非常适合这个任务。 ## 安装和设置的对比如何? 两者都通过NuGet提供简单的安装,但复杂程度不同。 ### 安装 IronPDF。 IronPDF的安装简单得惊人: ```shell :ProductInstall ``` 或者通过.NET CLI: ```shell :InstallCmd dotnet add package IronPdf ``` 该包包含所有必要的东西,包括Chrome渲染引擎。对于大多数用例,无需额外配置或依赖。 对于特定的部署场景,IronPDF提供: - **`IronPdf.Slim`**:轻量级包,在运行时下载特定平台的组件 - **`IronPdf.Linux`**:为Linux部署预配置 - **`IronPdf.MacOs`**:为macOS环境优化 ### 安装GemBox.Pdf GemBox.Pdf的基本PDF操作安装同样简单: ```shell :InstallCmd Install-Package GemBox.Pdf ``` 然而,要进行HTML到PDF的转换,您需要: ```shell :InstallCmd Install-Package GemBox.Document ``` 两者都需要许可证密钥配置: ```csharp // IronPDF License.LicenseKey = "YOUR-LICENSE-KEY"; // GemBox.Pdf ComponentInfo.SetLicense("YOUR-LICENSE-KEY"); ```

许可和定价有何不同? 了解许可证模型有助于确定每个解决方案的总拥有成本。 ### IronPDF许可 IronPDF提供透明的分级许可(截至2025年的价格): - **Lite License**:$799 - 1位开发者 - 1个项目 - 1年的支持和更新 - **Plus License**:$1,199 - 3位开发者 - 3个项目 - 1年的支持和更新 - **Professional License**:$2,399 - 10位开发者 - 10个项目 - 1年的支持和更新 **其他选项**: - 免版税再分发:+$2,399 - 提供SaaS/OEM许可 - [Iron Suite捆绑包](https://ironsoftware.com/suite/):$1,498,包含9个产品 **主要优点**: - 30天退款保证 - 永久许可(一次性购买) - 免费开发和测试 - 包含开发/登台/生产部署 ### GemBox.Pdf许可 GemBox提供每开发者许可: - **单一开发者**:$890 - 1位开发者 - 无限项目 - 1年的支持和更新 - 包括免版税的部署 **重要考虑**: - HTML到PDF需要GemBox.Document:额外$890 - HTML到PDF的总成本:至少$1,780 - 续费时有40%折扣(如果在到期前续费则为60%) - GemBox捆绑包:$2,200,包含7个产品 **主要优点**: - 30天退款保证 - 永久许可 - 包括无限部署 - 不需要服务器或OEM许可 ### 常见场景的成本对比 | 情景 | IronPDF成本 | GemBox成本 | |----------|--------------|-------------| | 单一开发者,HTML到PDF | $749 | $1,780 | | 3个开发者,仅PDF操作 | $1,499 | $2,670 | | 3个开发者,HTML到PDF | $1,199 | $5,340 | | 企业(10个开发者),完整功能 | $2,399 | $8,900+ | ## 你应该选择哪个库? 在IronPDF和GemBox.Pdf之间的选择取决于您的具体要求: ### 选择IronPDF当: - **HTML到PDF是主要需求**:IronPDF基于Chrome的渲染无与伦比 - **您需要现代网页支持**:全面CSS3, HTML5和JavaScript功能 - **快速开发很重要**:简单的API缩短了上市时间 - **您处理动态内容**:JavaScript执行捕获实时数据 - **需要跨平台部署**:云和容器化环境的优秀支持 - **预算是考虑因素**:较低的入门成本和针对HTML到PDF场景的更高价值 ### 选择GemBox.Pdf当: - **低层次的PDF控制是必需的**:直接访问PDF对象和结构 - **需要移动平台支持**:原生Android和iOS兼容性 - **OCR是核心需求**:无需额外依赖的内置OCR - **您主要处理现有PDF**:强大的操控和提取功能 - **不需要HTML到PDF**:避免为未使用的GemBox.Document支付费用 - **无限的部署很重要**:包括免版税的再分发 ### 当考虑同时使用两个库时: 有些组织发现同时使用两个库对他们应用程序的不同部分很有价值: - 用于报告生成和HTML到PDF转换的IronPDF - 用于表单处理和PDF操作的GemBox.Pdf ## 如何开始使用您选择的库 两个库均提供免费试用以评估其功能: ### 试用IronPDF 1. 安装NuGet包 2. 开发无需许可证密钥 3. 在试用模式下PDF上会有水印 4. 在试用期间提供完整功能访问 [下载IronPDF免费试用版](trial-license) ### 试用GemBox.Pdf 1. 安装NuGet包 2. 使用`ComponentInfo.SetLicense("FREE-LIMITED-KEY")` 3. 在免费模式下限于2页 4. 升级以消除限制 ## 视觉安装指南 对于偏好使用 Visual Studio 图形界面的开发人员,这里有一个逐步指南来安装这两种库: ### 创建新的ASP.NET项目 ![Visual Studio 新项目对话框中显示ASP.NET Web应用程序的选项,带有.NET Framework选项](/static-assets/pdf/blog/gembox-pdf-alternatives/gembox-pdf-alternative-1.png) *Visual Studio 创建ASP.NET Web应用程序的新项目对话框 - PDF生成项目的基础* ![ASP.NET 项目模板选择屏幕,高亮显示Web Forms选项以进行PDF库集成](/static-assets/pdf/blog/gembox-pdf-alternatives/gembox-pdf-alternative-2.png) *选择Web Forms作为项目模板 - 适用于IronPDF和GemBox.Pdf的实现* ### 通过NuGet安装PDF库 ![解决方案资源管理器上下文菜单显示“管理 NuGet 包” 选项以添加PDF库](/static-assets/pdf/blog/gembox-pdf-alternatives/gembox-pdf-alternative-3.png) *右键单击解决方案资源管理器中的项目以访问NuGet包管理器以进行库安装* ![Visual Studio项目菜单显示“管理 NuGet 包” 选项以安装PDF库](/static-assets/pdf/blog/gembox-pdf-alternatives/gembox-pdf-alternative-4.png) *通过Visual Studio中的项目菜单访问NuGet包管理器的替代方法* ![NuGet包管理器界面显示IronPDF安装及版本详情和描述](/static-assets/pdf/blog/gembox-pdf-alternatives/gembox-pdf-alternative-5.png) *通过NuGet包管理器安装IronPDF - 注意到全面的功能描述和下载次数* ### 替代安装方法 ![IronPDF官方网站下载页面显示直接DLL下载选项以便手动安装](/static-assets/pdf/blog/gembox-pdf-alternatives/gembox-pdf-alternative-6.png) *IronPDF的网站提供了直接DLL下载选项,用于不适合使用NuGet安装的情况* ## 结论 IronPDF和GemBox.Pdf都是高质量的.NET开发者PDF库,各有其独特的优势。 IronPDF在HTML到PDF转换方面表现出色,其Chrome渲染引擎使其非常适合现代Web应用程序和动态内容生成。 GemBox.Pdf在低级别PDF操作和移动支持方面表现优异,适合需要精确PDF控制的应用程序。 对于大多数Web开发人员和团队构建现代应用程序而言,IronPDF提供了最佳的功能、易用性和价值的组合。 它能够使用熟悉的Web技术从HTML渲染出像素完美的PDF,大大减少了开发时间和复杂性。 然而,对于专门的场景,特别是移动开发和专注于PDF表单处理或OCR需求的应用程序,GemBox.Pdf仍然是稳固的选择。 准备好将您的HTML内容转换为专业的PDF了吗? [开始使用IronPDF的免费试用版](trial-license),体验在.NET应用程序中Chrome品质渲染的强大功能。 凭借全面的文档、丰富的代码示例和快速响应的支持,您将在几分钟内而不是几个小时内生成PDF。 [{i:(GemBox.Pdf和GemBox.Document是其各自所有者的注册商标。 本网站与GemBox.Pdf或GemBox.Document无关联、未经认可或赞助。 所有产品名称、徽标和品牌均为其各自所有者的财产。 比较仅供参考,反映的是撰写时的公开信息。]

常见问题解答

如何在C#中将HTML转换为PDF?

你可以使用IronPDF的RenderHtmlAsPdf方法将HTML字符串转换为PDF。你还可以使用RenderHtmlFileAsPdf将HTML文件转换为PDF。

我可以使用这些库操作现有的PDF文件吗?

可以,IronPDF和GemBox.Pdf都可以用于操作现有的PDF文件。IronPDF简化了合并、拆分和添加水印等常见任务。GemBox.Pdf提供了对PDF对象的更细致控制,这对于复杂的操作任务非常有用。

使用IronPDF进行HTML到PDF转换的优势是什么?

IronPDF通过其Chrome V8渲染引擎提供了卓越的HTML到PDF转换质量,实现了98%以上的浏览器一致性。它支持现代CSS3、HTML5、JavaScript执行、Web字体和响应式设计。

对于一个小型开发团队,哪个库更具成本效益?

对于一个需要HTML到PDF转换的三人开发团队,IronPDF的Plus许可证费用为$1,499,而GemBox则需要$5,340购买3个GemBox.Pdf许可证和3个GemBox.Document许可证。IronPDF为团队提供了显著更好的价值。

IronPDF适合大批量PDF生成吗?

是的,IronPDF提供了卓越的性能,HTML到PDF的渲染时间约为125ms,优化的异步/等待支持,以及高效的内存使用,低于10MB。非常适合大批量的基于Web的PDF生成。

IronPDF包含什么样的支持?

IronPDF提供了24/5的工程支持,直接与开发团队联系,通常的响应时间为24-48小时,并附带全面的文档和代码示例。

我可以用这些库创建符合PDF/A标准的文档吗?

可以,IronPDF可以通过一个简单的方法调用,如SaveAsPdfA()生成符合PDF/A标准的文档,支持多个PDF/A版本。GemBox.Pdf可以读取PDF/A文档并在修改时保持合规。

这些库与现代.NET框架兼容吗?

是的,这两个库都支持现代.NET版本。IronPDF支持.NET Framework 4.6.2+、.NET Core 3.1+ 和 .NET 5 至 10。GemBox.Pdf支持.NET Framework 3.5+、.NET Standard 2.0 和.NET 6+。

哪个库为云部署进行了优化?

IronPDF为云部署进行了优化,特别支持Azure、AWS、Docker容器和无服务器环境。其基于HTML的方法自然适合Web应用,是SaaS应用程序的更佳选择。

是否有免费的版本可以测试IronPDF?

IronPDF提供了一个免费的评估选项,允许在没有许可证密钥的情况下进行无限制的开发和测试,尽管输出上会出现水印。这提供了在购买前评估产品的足够功能。

Jacob Mellor,Team Iron 的首席技术官
首席技术官

Jacob Mellor 是 Iron Software 的首席技术官,是 C# PDF 技术的先锋工程师。作为 Iron Software 核心代码库的原始开发者,自公司成立以来,他就塑造了公司的产品架构,并与首席执行官 Cameron Rimington 一起将其转变成一家公司,拥有50多人,服务于 NASA、特斯拉和全球政府机构。

Jacob 拥有曼彻斯特大学 (1998-2001) 的一级荣誉土木工程学士学位。1999 年在伦敦创办了自己的第一家软件公司,并于 2005 年创建了他的第一个 .NET 组件后,他专注于解决微软生态系统中的复杂问题。

他的旗舰 IronPDF 和 IronSuite .NET 库在全球已获得超过 3000 万次的 NuGet 安装,其基础代码继续为全球使用的开发者工具提供支持。拥有 25 年商业经验和 41 年编程经验的 Jacob 仍专注于推动企业级 C#、Java 和 Python PDF 技术的创新,同时指导下一代技术领导者。