如何用 C# 从 IronPDFium 迁移到 IronPDF
从 IronPdf.NET 迁移到 IronPDF,可以将您的 .NET PDF 工作流程从具有本地二进制依赖关系的、以渲染为重点的库转变为一个全面的 PDF 解决方案,该解决方案可以处理创建、操作和渲染,而不会产生特定平台的复杂性。 本指南提供了一个完整的、循序渐进的迁移路径,消除了本地依赖性管理,同时增加了 Pdfium 无法提供的功能。
为什么要从IronPDF迁移到 IronPDF.
了解 Pdfium.NET.
Pdfium.NET 是 Google PDFium 库的 .NET 封装程序,该库以高效、快速地渲染 PDF 文档而闻名。 它已成为开发人员在 C# 应用程序中钻研错综复杂的 PDF 渲染的重要库,可在 .NET 环境中高保真地复制 PDF 内容。
然而,尽管 Pdfium.NET 擅长渲染,但其创建和处理 PDF 文档的能力有限。 它主要适用于需要准确显示 PDF 内容的应用程序,而不太强调修改或创建新的 PDF。
关键软件限制
1.仅渲染焦点:无法从 HTML、图像或以编程方式创建 PDF。 Pdfium 的功能仅限于查看和渲染 PDF。
2.不支持 PDF 操作:无法合并、拆分或修改 PDF 内容。 本机不支持 PDF 合并,您需要使用 iTextSharp 或 PdfSharp 等其他库。
3.本地二进制依赖项:需要特定于平台的 PDFium 二进制文件。 开发人员需要管理本地 PDFium 二进制文件,这增加了部署和分发过程中的复杂性。
4.部署复杂性:必须将每个平台的本机 DLL 打包和管理,并包含 x86、x64 和运行时文件夹。
5.有限文本提取:基本文本提取,不进行格式化。 文本提取需要使用 Pdfium.NET 进行额外工作。
6.不支持 HTML 转 PDF:无法将网页内容转换为 PDF。 Pdfium.NET 本身不支持 HTML 到 PDF 的转换。
7.无页眉/页脚:无法添加页码或重复内容。
8.无水印:无法在带有叠加层的文档上加盖水印。
9.不支持表单:无法填写或读取 PDF 表单。
10.无安全功能:无法加密或密码保护 PDF 文件。
Pdfium 与IronPDF对比
| 方面 | Pdfium.NET | IronPDF |
|---|---|---|
| 主要关注点 | 渲染/查看 | 完整的 PDF 解决方案 |
| 渲染保真度 | 高保真渲染 | 高,尤其是 HTML/CSS/JS。 |
| PDF 创建 | ✗ | ✓ (HTML、URL、图片) |
| PDF 操作 | ✗ | ✓(合并、拆分、编辑) |
| HTML 到 PDF | ✗ | ✓(Chromium 引擎) |
| 水印。 | ✗ | ✓ |
| 页眉/页脚 | ✗ | ✓ |
| 表格填写 | ✗ | ✓ |
| 安全性 | ✗ | ✓ |
| 本地依赖关系 | 要求 | 无(完全托管) |
| 跨平台 | 复杂的设置 | 自动翻译 |
| 易于部署 | 因本地依赖性而复杂 | 更简单; 减少依赖复杂性 |
对于计划在 2025 年和 2026 年之前采用 .NET 10 和 C# 14 的团队来说,IronPDF 提供了一个完全可管理的基础,消除了本地二进制管理,同时增加了全面的 PDF 创建和操作功能。
开始之前
前提条件
- .NET 环境: .NET Framework 4.6.2+ 或 .NET Core 3.1+ / .NET 5/6/7/8/9+
- NuGet 访问权限:能够安装 NuGet 包
- IronPDF 许可证:请从ironpdf.com获取您的许可证密钥。
NuGet 软件包变更
# Remove Pdfium packages
dotnet remove package Pdfium.NET
dotnet remove package Pdfium.Net.SDK
dotnet remove package PdfiumViewer
# Install IronPDF
dotnet add package IronPdf
# Remove Pdfium packages
dotnet remove package Pdfium.NET
dotnet remove package Pdfium.Net.SDK
dotnet remove package PdfiumViewer
# Install IronPDF
dotnet add package IronPdf
许可配置
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
确定 Pdfium 的用法
# Find Pdfium usage
grep -r "Pdfium\|PdfDocument\.Load\|\.Render\(" --include="*.cs" .
# Find native binary references
grep -r "pdfium\.dll\|pdfium\.so\|pdfium\.dylib" --include="*.csproj" --include="*.config" .
# Find platform-specific code
grep -r "#if.*64\|WIN32\|WIN64\|LINUX\|OSX" --include="*.cs" .
# Find Pdfium usage
grep -r "Pdfium\|PdfDocument\.Load\|\.Render\(" --include="*.cs" .
# Find native binary references
grep -r "pdfium\.dll\|pdfium\.so\|pdfium\.dylib" --include="*.csproj" --include="*.config" .
# Find platform-specific code
grep -r "#if.*64\|WIN32\|WIN64\|LINUX\|OSX" --include="*.cs" .
完整的 API 参考
命名空间变更
// Pdfium.NET
using Pdfium;
using Pdfium.Net;
using PdfiumViewer;
// IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;
// Pdfium.NET
using Pdfium;
using Pdfium.Net;
using PdfiumViewer;
// IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;
Imports Pdfium
Imports Pdfium.Net
Imports PdfiumViewer
Imports IronPdf
Imports IronPdf.Rendering
Imports IronPdf.Editing
核心类映射
| Pdfium.NET | IronPDF |
|---|---|
PdfDocument |
PdfDocument |
PdfPage |
PdfPage |
PdfPageCollection |
PdfPageCollection |
| (不可用)_ | ChromePdfRenderer |
| (不可用)_ | HtmlHeaderFooter |
文档加载映射
| Pdfium.NET | IronPDF |
|---|---|
PdfDocument.Load(path) |
PdfDocument.FromFile(path) |
PdfDocument.Load(stream) |
PdfDocument.FromStream(stream) |
PdfDocument.Load(bytes) |
PdfDocument.FromBinaryData(bytes) |
new PdfDocument(path) |
PdfDocument.FromFile(path) |
文档属性映射
| Pdfium.NET | IronPDF |
|---|---|
document.PageCount |
document.PageCount |
document.Pages |
document.Pages |
document.Pages[index] |
document.Pages[index] |
document.GetPageSize(index) |
document.Pages[index].Width/Height |
文本提取映射
| Pdfium.NET | IronPDF |
|---|---|
document.GetPdfText(pageIndex) |
document.Pages[index].Text |
| (手动循环) | document.ExtractAllText() |
page.GetTextBounds() |
page.Text |
保存文档映射
| Pdfium.NET | IronPDF |
|---|---|
document.Save(path) |
document.SaveAs(path) |
document.Save(stream) |
document.Stream |
| (不可用)_ | document.BinaryData |
页面渲染映射
| Pdfium.NET | IronPDF |
|---|---|
page.Render(width, height) |
pdf.RasterizeToImageFiles(path, dpi) |
page.Render(width, height, flags) |
DPI 参数 |
document.Render(index, width, height) |
pdf.RasterizeToImageFiles() |
page.RenderToScale(scale) |
DPI:72 * scale |
Pdfium 中没有的新功能
| IronPDF 特点 | 说明 |
|---|---|
ChromePdfRenderer.RenderHtmlAsPdf() |
从 HTML 创建 |
ChromePdfRenderer.RenderUrlAsPdf() |
从 URL 创建 |
ChromePdfRenderer.RenderHtmlFileAsPdf() |
从 HTML 文件创建 |
PdfDocument.Merge() |
合并 PDF |
pdf.CopyPages() |
提取页面 |
pdf.RemovePages() |
删除页面 |
pdf.InsertPdf() |
在位置处插入 PDF |
pdf.ApplyWatermark() |
添加水印 |
pdf.AddHtmlHeaders() |
添加页眉 |
pdf.AddHtmlFooters() |
添加页脚 |
pdf.SecuritySettings |
密码保护 |
pdf.SignWithDigitalSignature() |
数字签名 |
pdf.Form |
表格填写 |
代码迁移示例
示例 1:从 PDF 中提取文本
之前 (Pdfium):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Text;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
using (var document = PdfDocument.Load(pdfPath))
{
StringBuilder text = new StringBuilder();
for (int i = 0; i < document.PageCount; i++)
{
// Note: PdfiumViewer has limited text extraction capabilities
// Text extraction requires additional work with Pdfium.NET
string pageText = document.GetPdfText(i);
text.AppendLine(pageText);
}
Console.WriteLine(text.ToString());
}
}
}
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Text;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
using (var document = PdfDocument.Load(pdfPath))
{
StringBuilder text = new StringBuilder();
for (int i = 0; i < document.PageCount; i++)
{
// Note: PdfiumViewer has limited text extraction capabilities
// Text extraction requires additional work with Pdfium.NET
string pageText = document.GetPdfText(i);
text.AppendLine(pageText);
}
Console.WriteLine(text.ToString());
}
}
}
Imports PdfiumViewer
Imports System
Imports System.IO
Imports System.Text
Module Program
Sub Main()
Dim pdfPath As String = "document.pdf"
Using document = PdfDocument.Load(pdfPath)
Dim text As New StringBuilder()
For i As Integer = 0 To document.PageCount - 1
' Note: PdfiumViewer has limited text extraction capabilities
' Text extraction requires additional work with Pdfium.NET
Dim pageText As String = document.GetPdfText(i)
text.AppendLine(pageText)
Next
Console.WriteLine(text.ToString())
End Using
End Sub
End Module
After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
var pdf = PdfDocument.FromFile(pdfPath);
string text = pdf.ExtractAllText();
Console.WriteLine(text);
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
var pdf = PdfDocument.FromFile(pdfPath);
string text = pdf.ExtractAllText();
Console.WriteLine(text);
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
Dim pdfPath As String = "document.pdf"
Dim pdf = PdfDocument.FromFile(pdfPath)
Dim text As String = pdf.ExtractAllText()
Console.WriteLine(text)
End Sub
End Class
这里的差异非常大。 Pdfium 需要手动遍历每个页面,使用 GetPdfText(pageIndex),构建 StringBuilder,并管理 using 语句以进行正确处置。 代码指出,"PdfiumViewer 的文本提取功能有限","文本提取需要额外的工作"。
IronPDF 将此简化为三行:使用 PdfDocument.FromFile() 加载,使用 ExtractAllText() 提取,然后输出。 ExtractAllText() 方法具有更高级的文本提取功能,可自动处理所有页面。 如果您需要按页提取,可以使用 pdf.Pages[index].Text。 有关其他选项,请参阅文本提取文档。
示例 2:PDF 合并
之前 (Pdfium):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Collections.Generic;
// Note: PdfiumViewer does not have native PDF merging functionality
// You would need to use additional libraries or implement custom logic
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
// PdfiumViewer is primarily for rendering/viewing
// PDF merging is not natively supported
// You would need to use another library like iTextSharp or PdfSharp
Console.WriteLine("PDF merging not natively supported in PdfiumViewer");
}
}
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Collections.Generic;
// Note: PdfiumViewer does not have native PDF merging functionality
// You would need to use additional libraries or implement custom logic
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
// PdfiumViewer is primarily for rendering/viewing
// PDF merging is not natively supported
// You would need to use another library like iTextSharp or PdfSharp
Console.WriteLine("PDF merging not natively supported in PdfiumViewer");
}
}
Imports PdfiumViewer
Imports System
Imports System.IO
Imports System.Collections.Generic
' Note: PdfiumViewer does not have native PDF merging functionality
' You would need to use additional libraries or implement custom logic
Class Program
Shared Sub Main()
Dim pdfFiles As New List(Of String) From {
"document1.pdf",
"document2.pdf",
"document3.pdf"
}
' PdfiumViewer is primarily for rendering/viewing
' PDF merging is not natively supported
' You would need to use another library like iTextSharp or PdfSharp
Console.WriteLine("PDF merging not natively supported in PdfiumViewer")
End Sub
End Class
After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
var pdf = PdfDocument.Merge(pdfFiles);
pdf.SaveAs("merged.pdf");
Console.WriteLine("PDFs merged successfully");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
var pdf = PdfDocument.Merge(pdfFiles);
pdf.SaveAs("merged.pdf");
Console.WriteLine("PDFs merged successfully");
}
}
Imports IronPdf
Imports System
Imports System.Collections.Generic
Module Program
Sub Main()
Dim pdfFiles As New List(Of String) From {
"document1.pdf",
"document2.pdf",
"document3.pdf"
}
Dim pdf = PdfDocument.Merge(pdfFiles)
pdf.SaveAs("merged.pdf")
Console.WriteLine("PDFs merged successfully")
End Sub
End Module
这个例子凸显了一个基本的能力差距。Pdfium 无法合并 PDF--代码明确指出 "PdfiumViewer 本身不支持 PDF 合并 "和 "您需要使用 iTextSharp 或 PdfSharp 等其他库"。
IronPDF 提供原生合并功能,其静态方法 PdfDocument.Merge() 可直接接受文件路径列表。 结果是一个新 PdfDocument,您可以将其保存为 SaveAs()。 了解有关 合并和拆分 PDF 的更多信息。
示例 3:HTML 到 PDF 的转换
之前 (Pdfium):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System.IO;
using System.Drawing.Printing;
// Note: PdfiumViewer is primarily for viewing/rendering PDFs, not creating them from HTML
// For HTML to PDF with Pdfium.NET, you would need additional libraries
// This example shows a limitation of Pdfium.NET
class Program
{
static void Main()
{
// Pdfium.NET does not have native HTML to PDF conversion
// You would need to use a separate library to convert HTML to PDF
// then use Pdfium for manipulation
string htmlContent = "<h1>Hello World</h1>";
// This functionality is not directly available in Pdfium.NET
Console.WriteLine("HTML to PDF conversion not natively supported in Pdfium.NET");
}
}
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System.IO;
using System.Drawing.Printing;
// Note: PdfiumViewer is primarily for viewing/rendering PDFs, not creating them from HTML
// For HTML to PDF with Pdfium.NET, you would need additional libraries
// This example shows a limitation of Pdfium.NET
class Program
{
static void Main()
{
// Pdfium.NET does not have native HTML to PDF conversion
// You would need to use a separate library to convert HTML to PDF
// then use Pdfium for manipulation
string htmlContent = "<h1>Hello World</h1>";
// This functionality is not directly available in Pdfium.NET
Console.WriteLine("HTML to PDF conversion not natively supported in Pdfium.NET");
}
}
Imports PdfiumViewer
Imports System.IO
Imports System.Drawing.Printing
' Note: PdfiumViewer is primarily for viewing/rendering PDFs, not creating them from HTML
' For HTML to PDF with Pdfium.NET, you would need additional libraries
' This example shows a limitation of Pdfium.NET
Class Program
Shared Sub Main()
' Pdfium.NET does not have native HTML to PDF conversion
' You would need to use a separate library to convert HTML to PDF
' then use Pdfium for manipulation
Dim htmlContent As String = "<h1>Hello World</h1>"
' This functionality is not directly available in Pdfium.NET
Console.WriteLine("HTML to PDF conversion not natively supported in Pdfium.NET")
End Sub
End Class
After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string htmlContent = "<h1>Hello World</h1>";
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string htmlContent = "<h1>Hello World</h1>";
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
Dim renderer = New ChromePdfRenderer()
Dim htmlContent As String = "<h1>Hello World</h1>"
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
pdf.SaveAs("output.pdf")
Console.WriteLine("PDF created successfully")
End Sub
End Class
本例展示了最显著的能力差异。 Pdfium 明确指出 "Pdfium.NET 不支持 HTML 到 PDF 的转换 "和 "您需要使用单独的库将 HTML 转换为 PDF"。
IronPDF 通过 ChromePdfRenderer 提供原生 HTML 到 PDF 的转换,它内部使用 Chromium 引擎来精确渲染 HTML、CSS 和 JavaScript。 RenderHtmlAsPdf() 方法直接将 HTML 字符串转换为 PDF 文档。IronPDF还可以渲染带有 RenderUrlAsPdf() 的 URL 和带有 RenderHtmlFileAsPdf() 的 HTML 文件。 请参阅 HTML 转 PDF 文档,了解全面的示例。
本地依赖关系移除
从IronPDF迁移到IronPDF的最大好处之一是消除了本地二进制管理。
之前 (Pdfium) - 复杂部署
MyApp/
├─── bin/
│ ├─── MyApp.dll
│ ├── Pdfium.NET.dll
│ ├── x86/
│ │ └── pdfium.dll
│ └── x64/
│ └── pdfium.dll
运行时
│ ├─── win-x86/native/
│ │ └── pdfium.dll
│ └───-win-x64/native/
│ └── pdfium.dll
后 (IronPDF) - 清洁部署
MyApp/
├─── bin/
│ ├─── MyApp.dll
│ └─── IronPDF.dll # 包含的所有内容
移除本地二进制引用
# Delete native PDFium binaries
rm -rf x86/ x64/ runtimes/
# Remove from .csproj
# Delete any <Content Include="pdfium.dll" /> entries
# Delete any <None Include="x86/pdfium.dll" /> entries
# Delete native PDFium binaries
rm -rf x86/ x64/ runtimes/
# Remove from .csproj
# Delete any <Content Include="pdfium.dll" /> entries
# Delete any <None Include="x86/pdfium.dll" /> entries
关键迁移说明
缩放比例到 DPI 转换
Pdfium 使用比例系数;IronPDF使用 DPI:
// Formula:IronPDFDPI = 72 × Pdfium scale
// Pdfium scale 2.0 →IronPDFDPI 144
pdf.RasterizeToImageFiles("*.png", DPI: 144);
// Formula:IronPDFDPI = 72 × Pdfium scale
// Pdfium scale 2.0 →IronPDFDPI 144
pdf.RasterizeToImageFiles("*.png", DPI: 144);
' Formula: IronPDFDPI = 72 × Pdfium scale
' Pdfium scale 2.0 → IronPDFDPI 144
pdf.RasterizeToImageFiles("*.png", DPI:=144)
文档加载方法更改
// Pdfium
PdfDocument.Load(path)
// IronPDF
PdfDocument.FromFile(path)
// Pdfium
PdfDocument.Load(path)
// IronPDF
PdfDocument.FromFile(path)
保存方法更改
// Pdfium
document.Save(path)
// IronPDF
pdf.SaveAs(path)
// Pdfium
document.Save(path)
// IronPDF
pdf.SaveAs(path)
处置模式简化
// Pdfium:要求explicit disposal
using (var document = PdfDocument.Load(path))
using (var page = document.Pages[0])
using (var bitmap = page.Render(1024, 768))
{
bitmap.Save("output.png");
}
// IronPDF: Simplified
var pdf = PdfDocument.FromFile(path);
pdf.RasterizeToImageFiles("output.png");
// Pdfium:要求explicit disposal
using (var document = PdfDocument.Load(path))
using (var page = document.Pages[0])
using (var bitmap = page.Render(1024, 768))
{
bitmap.Save("output.png");
}
// IronPDF: Simplified
var pdf = PdfDocument.FromFile(path);
pdf.RasterizeToImageFiles("output.png");
Imports Pdfium
Imports IronPDF
' Pdfium:要求explicit disposal
Using document = PdfDocument.Load(path)
Using page = document.Pages(0)
Using bitmap = page.Render(1024, 768)
bitmap.Save("output.png")
End Using
End Using
End Using
' IronPDF: Simplified
Dim pdf = PdfDocument.FromFile(path)
pdf.RasterizeToImageFiles("output.png")
删除特定平台的代码
// Pdfium:要求platform detection
#if WIN64
// Load x64 pdfium.dll
#else
// Load x86 pdfium.dll
#endif
// IronPDF: Remove all platform-specific code
// Just use the API directly
// Pdfium:要求platform detection
#if WIN64
// Load x64 pdfium.dll
#else
// Load x86 pdfium.dll
#endif
// IronPDF: Remove all platform-specific code
// Just use the API directly
功能对比摘要
| 特征 | Pdfium.NET | IronPDF |
|---|---|---|
| 加载 PDF | ✓ | ✓ |
| 渲染为图像 | ✓ | ✓ |
| 提取文本 | ✓ (基本) | ✓(高级) |
| 页面信息 | ✓ | ✓ |
| 从 HTML 创建 | ✗ | ✓ |
| 从 URL 创建 | ✗ | ✓ |
| 合并 PDF | ✗ | ✓ |
| 拆分 PDF | ✗ | ✓ |
| 添加水印 | ✗ | ✓ |
| 页眉/页脚 | ✗ | ✓ |
| 表格填写 | ✗ | ✓ |
| 数字签名 | ✗ | ✓ |
| 密码保护 | ✗ | ✓ |
| 本地依赖性 | 要求 | 无 |
| 跨平台 | 复杂 | 自动翻译 |
| 内存管理 | 手册处理 | 简化 |
迁移清单
迁移前
- 识别代码库中所有 Pdfium 的使用情况
- 记录当前使用的渲染尺寸/比例
- 列出项目中的本地二进制文件位置
- 检查平台特定的加载代码
- 确定PDF创建需求(目前是否使用不同的工具?)
- 审查转换处置模式
- 获取IronPDF许可证密钥
软件包变更
- 删除
Pdfium.NET、Pdfium.Net.SDK、PdfiumViewerNuGet 包 - 从 x86/、x64/ 和 runtimes/ 文件夹中删除本地 pdfium.dll 二进制文件
- 移除平台特定的条件编译
- 更新 .csproj 文件以移除原生二进制引用
安装
IronPdfNuGet 包:dotnet add package IronPdf
代码更改
- 在启动时添加许可证密钥配置
- 将
PdfDocument.Load()替换为PdfDocument.FromFile() - 将
document.Save()替换为pdf.SaveAs() - 将
document.GetPdfText(i)循环替换为pdf.ExtractAllText() - 将比例因子转换为 DPI 值(DPI = 72 × 比例)
- 简化资源释放模式(移除嵌套的 using 语句)
- 删除平台特定代码
后迁移
- 测试渲染输出质量
- 比较文本提取结果
- 测试跨平台部署
- 添加新功能(HTML 转 PDF、合并、水印、安全)
- 更新文档

