跳至页脚内容
迁移指南

如何用 C# 从 Gnostice PDFOne 迁移到 IronPDF

从Gnostice PDFOne迁移到IronPDF可将您的 .NET PDF 工作流程从基于坐标、平台分散的方法转变为完全支持现代网络标准的统一、HTML/CSS 驱动的解决方案。 本指南为专业的 .NET 开发人员提供了一个全面的、循序渐进的迁移路径,消除了围绕 CSS、JavaScript 和内存稳定性的文档限制。

为什么要从Gnostice PDFOne迁移到 IronPDF.

Gnostice PDFOne的挑战

Gnostice PDFOne 和 Document Studio .NET 有充分记录的限制会影响生产应用:

1.不支持外部 CSS:Gnostice PDFOne的文档明确指出它不支持外部 CSS 样式表——这是现代 Web 到 PDF 转换的基本要求。

2.无法执行 JavaScript:需要 JavaScript 的动态内容无法渲染,因此无法准确地转换现代 Web 应用程序。

3.不支持直接 HTML 转 PDF:Gnostice PDFOne不支持直接 HTML 转 PDF 转换。 您需要使用 Document Studio 进行 HTML 转换,或者手动解析和渲染 HTML 元素--这是一笔不小的开发开销。

4.平台碎片化: WinForms、WPF、ASP.NET 和 Xamarin 各自拥有独立的产品,功能集和 API 也各不相同。您可能需要多个许可证和代码库。

5.内存泄漏和稳定性:用户论坛和 Stack Overflow 报告称,在处理图像时存在持续的内存泄漏、JPEG 错误 #53 和 StackOverflow 异常。

6.不支持从右到左的 Unicode:明确不支持阿拉伯语、希伯来语和其他 RTL 语言——这对国际应用来说是一个致命缺陷。

7.数字签名支持有限:Gnostice PDFOne一直以来都缺少数字签名功能或数字签名功能不可靠。

8.基于坐标的 API:许多操作需要手动 X/Y 定位,而不是现代布局方法,因此每个元素的放置都需要精确计算。

Gnostice PDFOne与IronPDF对比

方面 Gnostice PDFOne IronPDF
外部 CSS 不支持 支持
JavaScript 执行 不支持 完整的 Chromium 引擎
RTL 语言 不支持 完全支持 Unicode
数字签名 有限/缺失 完全支持 X509
平台 零散的产品 单一的统一库
内存稳定性 报告的问题 稳定、管理良好
HTML 转 PDF 基本,需要变通 Chrome 浏览器质量的渲染
学习曲线 复杂的 API 简单直观的 API
现代 CSS(Flexbox、网格) 不支持 完全支持 CSS3
图像处理 已知问题 可靠

对于计划在 2025 年和 2026 年之前采用 .NET 10 和 C# 14 的团队来说,IronPDF 提供了一个面向未来的基础,其统一的库可在所有 .NET 平台上一致运行。


迁移复杂性评估

按功能估算的工作量

特征 迁移复杂性
加载/保存 PDF 极低
合并 PDF 极低
拆分 PDF low
文本提取 low
水印 low
页眉/页脚 low
HTML 至 PDF low
加密 语言
表格字段 语言
数字签名 low

您将获得的功能

当从Gnostice PDFOne迁移到IronPDF时,这些以前不可能实现的功能将变得可用:

  • 外部 CSS 样式表
  • JavaScript 执行
  • 支持 RTL 语言(阿拉伯语、希伯来语)
  • CSS 网格和 Flexbox
  • 可靠的数字签名
  • 更好的内存管理
  • 通过单一代码库实现跨平台支持

开始之前

前提条件

  1. .NET 版本:IronPDF支持 .NET Framework 4.6.2+ 和 .NET Core 2.0+ / .NET 5/6/7/8/9+ 2.许可证密钥:ironpdf.com获取您的IronPDF许可证密钥。 3.备份:创建一个用于迁移工作的分支

识别所有Gnostice PDFOne使用情况

# Find all Gnostice references
grep -r "Gnostice\|PDFOne\|PDFDocument\|PDFPage\|DocExporter" --include="*.cs" .

# Find package references
grep -r "Gnostice\|PDFOne" --include="*.csproj" .
# Find all Gnostice references
grep -r "Gnostice\|PDFOne\|PDFDocument\|PDFPage\|DocExporter" --include="*.cs" .

# Find package references
grep -r "Gnostice\|PDFOne" --include="*.csproj" .
SHELL

NuGet 软件包变更

# RemoveGnostice PDFOnepackages
dotnet remove package PDFOne.NET
dotnet remove package Gnostice.DocumentStudio.NET
dotnet remove package Gnostice.PDFOne.NET
dotnet remove package Gnostice.XtremeDocumentStudio.NET

# Install IronPDF
dotnet add package IronPdf
# RemoveGnostice PDFOnepackages
dotnet remove package PDFOne.NET
dotnet remove package Gnostice.DocumentStudio.NET
dotnet remove package Gnostice.PDFOne.NET
dotnet remove package Gnostice.XtremeDocumentStudio.NET

# Install IronPDF
dotnet add package IronPdf
SHELL

快速启动迁移

步骤 1:更新许可配置

之前(Gnostice PDFOne):

// Gnostice license often set via config or property
PDFOne.License.LicenseKey = "YOUR-GNOSTICE-LICENSE";
// Gnostice license often set via config or property
PDFOne.License.LicenseKey = "YOUR-GNOSTICE-LICENSE";
' Gnostice license often set via config or property
PDFOne.License.LicenseKey = "YOUR-GNOSTICE-LICENSE"
$vbLabelText   $csharpLabel

After (IronPDF):

// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";

// Or in appsettings.json:
// { "IronPdf.License.LicenseKey": "YOUR-LICENSE-KEY" }
// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";

// Or in appsettings.json:
// { "IronPdf.License.LicenseKey": "YOUR-LICENSE-KEY" }
' Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"

' Or in appsettings.json:
' { "IronPdf.License.LicenseKey": "YOUR-LICENSE-KEY" }
$vbLabelText   $csharpLabel

步骤 2:更新名称空间导入

// Before (Gnostice PDFOne)
using Gnostice.PDFOne;
using Gnostice.PDFOne.Document;
using Gnostice.PDFOne.Graphics;

// After (IronPDF)
using IronPdf;
using IronPdf.Editing;
// Before (Gnostice PDFOne)
using Gnostice.PDFOne;
using Gnostice.PDFOne.Document;
using Gnostice.PDFOne.Graphics;

// After (IronPDF)
using IronPdf;
using IronPdf.Editing;
Imports IronPdf
Imports IronPdf.Editing
$vbLabelText   $csharpLabel

完整的 API 参考

核心类映射

Gnostice PDFOne IronPDF 说明
PDFDocument PdfDocument 主要 PDF 文档类别
PDFPage PdfDocument.Pages[i] 页面表示
PDFFont CSS 定型 字体规格
PDFTextElement HTML 内容 文本内容
PDFImageElement HTML 标签 图片内容
DocExporter ChromePdfRenderer HTML/URL 到 PDF 的转换

文档操作

Gnostice PDFOne IronPDF
new PDFDocument() new PdfDocument()
doc.Load(path) PdfDocument.FromFile(path)
doc.Open() 不适用(自动)
doc.Save(path) pdf.SaveAs(path)
doc.Close() pdf.Dispose()
doc.Pages.Count pdf.PageCount
doc.Pages.Add() 渲染 HTML 或合并

合并操作

Gnostice PDFOne IronPDF
doc.Append(otherDoc) PdfDocument.Merge(pdf1, pdf2)
多次 Append() 调用 PdfDocument.Merge(list)

代码迁移示例

示例 1:HTML 到 PDF 的转换

之前(Gnostice PDFOne):

// NuGet: Install-Package Gnostice.PDFOne.DLL
using Gnostice.PDFOne;
using Gnostice.PDFOne.Graphics;
using System;

class Program
{
    static void Main()
    {
        PDFDocument doc = new PDFDocument();
        doc.Open();

        PDFPage page = doc.Pages.Add();

        // PDFOne doesn't have directHTML 至 PDFconversion
        // You need to use Document Studio for HTML conversion
        // Or manually parse and render HTML elements

        PDFTextElement textElement = new PDFTextElement();
        textElement.Text = "Simple text conversion instead of HTML";
        textElement.Draw(page, 10, 10);

        doc.Save("output.pdf");
        doc.Close();
    }
}
// NuGet: Install-Package Gnostice.PDFOne.DLL
using Gnostice.PDFOne;
using Gnostice.PDFOne.Graphics;
using System;

class Program
{
    static void Main()
    {
        PDFDocument doc = new PDFDocument();
        doc.Open();

        PDFPage page = doc.Pages.Add();

        // PDFOne doesn't have directHTML 至 PDFconversion
        // You need to use Document Studio for HTML conversion
        // Or manually parse and render HTML elements

        PDFTextElement textElement = new PDFTextElement();
        textElement.Text = "Simple text conversion instead of HTML";
        textElement.Draw(page, 10, 10);

        doc.Save("output.pdf");
        doc.Close();
    }
}
Imports Gnostice.PDFOne
Imports Gnostice.PDFOne.Graphics
Imports System

Module Program
    Sub Main()
        Dim doc As New PDFDocument()
        doc.Open()

        Dim page As PDFPage = doc.Pages.Add()

        ' PDFOne doesn't have direct HTML to PDF conversion
        ' You need to use Document Studio for HTML conversion
        ' Or manually parse and render HTML elements

        Dim textElement As New PDFTextElement()
        textElement.Text = "Simple text conversion instead of HTML"
        textElement.Draw(page, 10, 10)

        doc.Save("output.pdf")
        doc.Close()
    End Sub
End Module
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string html = "<h1>Hello World</h1><p>This is HTML content.</p>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string html = "<h1>Hello World</h1><p>This is HTML content.</p>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()

        Dim html As String = "<h1>Hello World</h1><p>This is HTML content.</p>"

        Dim pdf = renderer.RenderHtmlAsPdf(html)
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

这其中的差别是巨大的:Gnostice PDFOne 无法直接将 HTML 转换为 PDF,您必须手动创建文本元素并用坐标定位。IronPDF的 ChromePdfRenderer 提供直接 HTML 渲染,并完全支持 CSS3 和 JavaScript。 请参阅 HTML to PDF 文档,了解更多渲染选项。

示例 2:合并 PDF 文件

之前(Gnostice PDFOne):

// NuGet: Install-Package Gnostice.PDFOne.DLL
using Gnostice.PDFOne;
using Gnostice.PDFOne.Document;
using System;

class Program
{
    static void Main()
    {
        PDFDocument doc1 = new PDFDocument();
        doc1.Load("document1.pdf");

        PDFDocument doc2 = new PDFDocument();
        doc2.Load("document2.pdf");

        PDFDocument mergedDoc = new PDFDocument();
        mergedDoc.Open();

        mergedDoc.Append(doc1);
        mergedDoc.Append(doc2);

        mergedDoc.Save("merged.pdf");

        doc1.Close();
        doc2.Close();
        mergedDoc.Close();
    }
}
// NuGet: Install-Package Gnostice.PDFOne.DLL
using Gnostice.PDFOne;
using Gnostice.PDFOne.Document;
using System;

class Program
{
    static void Main()
    {
        PDFDocument doc1 = new PDFDocument();
        doc1.Load("document1.pdf");

        PDFDocument doc2 = new PDFDocument();
        doc2.Load("document2.pdf");

        PDFDocument mergedDoc = new PDFDocument();
        mergedDoc.Open();

        mergedDoc.Append(doc1);
        mergedDoc.Append(doc2);

        mergedDoc.Save("merged.pdf");

        doc1.Close();
        doc2.Close();
        mergedDoc.Close();
    }
}
Imports Gnostice.PDFOne
Imports Gnostice.PDFOne.Document
Imports System

Module Program
    Sub Main()
        Dim doc1 As New PDFDocument()
        doc1.Load("document1.pdf")

        Dim doc2 As New PDFDocument()
        doc2.Load("document2.pdf")

        Dim mergedDoc As New PDFDocument()
        mergedDoc.Open()

        mergedDoc.Append(doc1)
        mergedDoc.Append(doc2)

        mergedDoc.Save("merged.pdf")

        doc1.Close()
        doc2.Close()
        mergedDoc.Close()
    End Sub
End Module
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        var merged = PdfDocument.Merge(pdf1, pdf2);
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        var merged = PdfDocument.Merge(pdf1, pdf2);
        merged.SaveAs("merged.pdf");
    }
}
Imports IronPdf
Imports System
Imports System.Collections.Generic

Module Program
    Sub Main()
        Dim pdf1 = PdfDocument.FromFile("document1.pdf")
        Dim pdf2 = PdfDocument.FromFile("document2.pdf")

        Dim merged = PdfDocument.Merge(pdf1, pdf2)
        merged.SaveAs("merged.pdf")
    End Sub
End Module
$vbLabelText   $csharpLabel

Gnostice PDFOne 方法需要创建一个新文档、打开它、分别加载源文档、添加每个文档并手动关闭所有三个文档。IronPDF的静态 Merge 方法通过适当的资源管理,仅用三行代码即可处理此问题。 了解有关 合并和拆分 PDF 的更多信息。

示例 3:为 PDF 添加水印

之前(Gnostice PDFOne):

// NuGet: Install-Package Gnostice.PDFOne.DLL
using Gnostice.PDFOne;
using Gnostice.PDFOne.Graphics;
using System;
using System.Drawing;

class Program
{
    static void Main()
    {
        PDFDocument doc = new PDFDocument();
        doc.Load("input.pdf");

        PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 48);

        foreach (PDFPage page in doc.Pages)
        {
            PDFTextElement watermark = new PDFTextElement();
            watermark.Text = "CONFIDENTIAL";
            watermark.Font = font;
            watermark.Color = Color.FromArgb(128, 255, 0, 0);
            watermark.RotationAngle = 45;

            watermark.Draw(page, 200, 400);
        }

        doc.Save("watermarked.pdf");
        doc.Close();
    }
}
// NuGet: Install-Package Gnostice.PDFOne.DLL
using Gnostice.PDFOne;
using Gnostice.PDFOne.Graphics;
using System;
using System.Drawing;

class Program
{
    static void Main()
    {
        PDFDocument doc = new PDFDocument();
        doc.Load("input.pdf");

        PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 48);

        foreach (PDFPage page in doc.Pages)
        {
            PDFTextElement watermark = new PDFTextElement();
            watermark.Text = "CONFIDENTIAL";
            watermark.Font = font;
            watermark.Color = Color.FromArgb(128, 255, 0, 0);
            watermark.RotationAngle = 45;

            watermark.Draw(page, 200, 400);
        }

        doc.Save("watermarked.pdf");
        doc.Close();
    }
}
Imports Gnostice.PDFOne
Imports Gnostice.PDFOne.Graphics
Imports System
Imports System.Drawing

Module Program
    Sub Main()
        Dim doc As New PDFDocument()
        doc.Load("input.pdf")

        Dim font As New PDFFont(PDFStandardFont.Helvetica, 48)

        For Each page As PDFPage In doc.Pages
            Dim watermark As New PDFTextElement()
            watermark.Text = "CONFIDENTIAL"
            watermark.Font = font
            watermark.Color = Color.FromArgb(128, 255, 0, 0)
            watermark.RotationAngle = 45

            watermark.Draw(page, 200, 400)
        Next

        doc.Save("watermarked.pdf")
        doc.Close()
    End Sub
End Module
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        var watermark = new TextStamper()
        {
            Text = "CONFIDENTIAL",
            FontSize = 48,
            Opacity = 50,
            Rotation = 45,
            VerticalAlignment = VerticalAlignment.Middle,
            HorizontalAlignment = HorizontalAlignment.Center
        };

        pdf.ApplyStamp(watermark);
        pdf.SaveAs("watermarked.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        var watermark = new TextStamper()
        {
            Text = "CONFIDENTIAL",
            FontSize = 48,
            Opacity = 50,
            Rotation = 45,
            VerticalAlignment = VerticalAlignment.Middle,
            HorizontalAlignment = HorizontalAlignment.Center
        };

        pdf.ApplyStamp(watermark);
        pdf.SaveAs("watermarked.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Editing
Imports System

Module Program
    Sub Main()
        Dim pdf = PdfDocument.FromFile("input.pdf")

        Dim watermark = New TextStamper() With {
            .Text = "CONFIDENTIAL",
            .FontSize = 48,
            .Opacity = 50,
            .Rotation = 45,
            .VerticalAlignment = VerticalAlignment.Middle,
            .HorizontalAlignment = HorizontalAlignment.Center
        }

        pdf.ApplyStamp(watermark)
        pdf.SaveAs("watermarked.pdf")
    End Sub
End Module
$vbLabelText   $csharpLabel

Gnostice PDFOne 方法需要创建 PDFFont 对象,手动遍历页面,计算坐标 (200, 400),并设置 PDFTextElement 对象的属性。IronPDF的 TextStamper 提供声明式配置,具有自动居中和页面应用功能——无需坐标计算。 请参阅水印文档以了解更多选项。


关键迁移说明

基于坐标的 HTML/CSS 布局

此次Gnostice PDFOne迁移中最重要的模式转变是从基于坐标的定位转向 HTML/CSS 布局:

// Gnostice PDFOne: Manual coordinate positioning
watermark.Draw(page, 200, 400);  // X=200, Y=400

// IronPDF: Declarative alignment
watermark.VerticalAlignment = VerticalAlignment.Middle;
watermark.HorizontalAlignment = HorizontalAlignment.Center;
// Gnostice PDFOne: Manual coordinate positioning
watermark.Draw(page, 200, 400);  // X=200, Y=400

// IronPDF: Declarative alignment
watermark.VerticalAlignment = VerticalAlignment.Middle;
watermark.HorizontalAlignment = HorizontalAlignment.Center;
' Gnostice PDFOne: Manual coordinate positioning
watermark.Draw(page, 200, 400)  ' X=200, Y=400

' IronPDF: Declarative alignment
watermark.VerticalAlignment = VerticalAlignment.Middle
watermark.HorizontalAlignment = HorizontalAlignment.Center
$vbLabelText   $csharpLabel

从字体对象到 CSS 风格

// Gnostice PDFOne
PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 48);
watermark.Font = font;

//IronPDF- use CSS in HTML content
var html = "<span style='font-family: Helvetica, Arial, sans-serif; font-size: 48pt;'>Text</span>";
// Gnostice PDFOne
PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 48);
watermark.Font = font;

//IronPDF- use CSS in HTML content
var html = "<span style='font-family: Helvetica, Arial, sans-serif; font-size: 48pt;'>Text</span>";
Imports Gnostice.PDFOne

' Gnostice PDFOne
Dim font As New PDFFont(PDFStandardFont.Helvetica, 48)
watermark.Font = font

' IronPDF- use CSS in HTML content
Dim html As String = "<span style='font-family: Helvetica, Arial, sans-serif; font-size: 48pt;'>Text</span>"
$vbLabelText   $csharpLabel

页面索引

Gnostice PDFOne 经常使用 1-indexed 页面,而IronPDF则使用 0-indexed 页面(标准 .NET 约定):

// Gnostice PDFOne: May use 1-indexed
var page = doc.Pages[1];  // First page

// IronPDF: 0-indexed
var page = pdf.Pages[0];  // First page
// Gnostice PDFOne: May use 1-indexed
var page = doc.Pages[1];  // First page

// IronPDF: 0-indexed
var page = pdf.Pages[0];  // First page
' Gnostice PDFOne: May use 1-indexed
Dim page = doc.Pages(1)  ' First page

' IronPDF: 0-indexed
Dim page = pdf.Pages(0)  ' First page
$vbLabelText   $csharpLabel

现在可用的功能

从Gnostice PDFOne迁移到IronPDF后,这些以前存在问题或不可能实现的功能变得可用: -外部 CSS:之前在Gnostice PDFOne中无法正常工作的样式表现在可以正确渲染了。

  • JavaScript 内容:之前缺失的动态内容现在已显示。
  • RTL 语言:阿拉伯语、希伯来语和其他从右到左的语言都能正常工作。
  • CSS Grid 和 Flexbox:完全支持现代布局技术 -数字签名:可靠的 X509 证书签名

故障排除

问题 1:PDFTextElement 未找到

问题:IronPDF中不存在 PDFTextElement

解决方案:使用 HTML 内容或 TextStamper:

// For new documents - render HTML
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<p>Your text here</p>");

// For existing documents - use stampers
var stamper = new TextStamper() { Text = "Added Text" };
pdf.ApplyStamp(stamper);
// For new documents - render HTML
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<p>Your text here</p>");

// For existing documents - use stampers
var stamper = new TextStamper() { Text = "Added Text" };
pdf.ApplyStamp(stamper);
Imports IronPdf

' For new documents - render HTML
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<p>Your text here</p>")

' For existing documents - use stampers
Dim stamper As New TextStamper() With {.Text = "Added Text"}
pdf.ApplyStamp(stamper)
$vbLabelText   $csharpLabel

第 2 期:PDFFont 对象

问题:Gnostice PDFOne使用 PDFFont 对象;IronPDF使用 CSS。

解决方案:

// Gnostice PDFOne
PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 12);

//IronPDF- use CSS
var html = "<span style='font-family: Helvetica, Arial, sans-serif; font-size: 12pt;'>Text</span>";
// Gnostice PDFOne
PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 12);

//IronPDF- use CSS
var html = "<span style='font-family: Helvetica, Arial, sans-serif; font-size: 12pt;'>Text</span>";
' Gnostice PDFOne
Dim font As New PDFFont(PDFStandardFont.Helvetica, 12)

' IronPDF- use CSS
Dim html = "<span style='font-family: Helvetica, Arial, sans-serif; font-size: 12pt;'>Text</span>"
$vbLabelText   $csharpLabel

问题 3:DocExporter 未找到。

问题:IronPDF中不存在 DocExporter 类。

解决方案:使用 ChromePdfRenderer:

// Gnostice PDFOne
DocExporter exporter = new DocExporter();
exporter.Export(doc, "output.pdf", DocumentFormat.PDF);

// IronPDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlFileAsPdf("input.html");
pdf.SaveAs("output.pdf");
// Gnostice PDFOne
DocExporter exporter = new DocExporter();
exporter.Export(doc, "output.pdf", DocumentFormat.PDF);

// IronPDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlFileAsPdf("input.html");
pdf.SaveAs("output.pdf");
' Gnostice PDFOne
Dim exporter As New DocExporter()
exporter.Export(doc, "output.pdf", DocumentFormat.PDF)

' IronPDF
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlFileAsPdf("input.html")
pdf.SaveAs("output.pdf")
$vbLabelText   $csharpLabel

第 4 期:内存改进

问题:Gnostice PDFOne报告存在内存泄漏。

解决方案:IronPDF提供稳定的内存管理。 使用正确的处理模式:

using (var pdf = PdfDocument.FromFile("large.pdf"))
{
    // Process PDF
    pdf.SaveAs("output.pdf");
}  // Automatically disposed
using (var pdf = PdfDocument.FromFile("large.pdf"))
{
    // Process PDF
    pdf.SaveAs("output.pdf");
}  // Automatically disposed
Imports PdfDocument

Using pdf = PdfDocument.FromFile("large.pdf")
    ' Process PDF
    pdf.SaveAs("output.pdf")
End Using
$vbLabelText   $csharpLabel

迁移清单

迁移前

  • 清点代码库中所有Gnostice PDFOne的使用情况
  • 注意之前无法正常工作的功能(CSS、JS、RTL)——现在它们都能正常工作了!
  • 文档内存问题,用于对比测试
  • 获取IronPDF许可证密钥
  • 在版本控制系统中创建迁移分支

代码迁移

  • 移除Gnostice PDFOneNuGet 包
  • 安装 IronPdf NuGet 包:dotnet add package IronPdf
  • 更新命名空间导入
  • 更换许可证密钥设置
  • PDFDocument 转换为 PdfDocument
  • DocExporter 转换为 ChromePdfRenderer
  • 将基于坐标的绘图替换为 HTML 戳记
  • PDFFont 更新为 CSS 样式
  • doc.Append() 转换为 PdfDocument.Merge()

测试

  • 测试 HTML 到 PDF 的转换
  • 验证外部 CSS 现在有效
  • 测试依赖于 JavaScript 的内容
  • 测试 RTL 语言(如有需要)
  • 测试数字签名(现已推出!)
  • 测试 PDF 合并
  • 测试水印
  • 比较内存使用情况

后迁移

  • 移除 Gnostic PDFOne 许可证
  • 更新文档
  • 移除针对Gnostice PDFOne限制的变通方案
  • 培训团队使用IronPDFAPI

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

钢铁支援团队

我们每周 5 天,每天 24 小时在线。
聊天
电子邮件
打电话给我