跳過到頁腳內容
遷移指南

如何在 C# 中從 IronPDFium 遷移到 IronPDF

從IronPDFfor .NET 轉換到 IronPDF,可將您的 .NET PDF 工作流程從一個以渲染為重點、具有本機二進位相依性的函式庫,轉換為一個全面的 PDF 解決方案,可處理建立、操作和渲染,而無需特定平台的複雜性。 本指南提供完整的逐步遷移路徑,可消除本機相依性管理,同時增加 Pdfium 無法提供的功能。

為何要從IronPDF轉移到 IronPDF?

瞭解 Pdfium.NET

Pdfium.NET 是 Google PDFium 函式庫的 .NET wrapper,該函式庫以其渲染 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 vsIronPDF比較

範疇 Pdfium.NET IronPDF
主要焦點 渲染/檢視 完整的 PDF 解決方案
渲染保真度 高保真渲染 高,尤其是 HTML/CSS/JS。
PDF製作 ✓(HTML、URL、圖片)
PDF 操作 ✓(合併、分割、編輯)
HTML至PDF ✓(Chromium 引擎)
水印
頁首/頁腳
表格填寫
安全性
本機依賴性 要求 無(完全管理)
跨平台 複雜的設定 自動化
易於部署 因本機依賴性而變得複雜 更輕鬆; 減少依賴複雜性

對於計劃在 2025 年和 2026 年之前採用 .NET 10 和 C# 14 的團隊而言,IronPDF 提供了一個完全可管理的基礎,可省去本機二進位管理,同時增加全面的 PDF 建立和操作功能。


開始之前

先決條件

  1. .NET環境: .NET Framework 4.6.2+ 或.NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGet存取權限:能夠安裝NuGet套件
  3. IronPDF許可證:請從IronPDF取得您的許可證密鑰。

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
SHELL

授權組態

// 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"
$vbLabelText   $csharpLabel

辨識 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" .
SHELL

完整的 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
$vbLabelText   $csharpLabel

核心類對應

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
$vbLabelText   $csharpLabel

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
$vbLabelText   $csharpLabel

這裡的差異非常大。 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
$vbLabelText   $csharpLabel

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
$vbLabelText   $csharpLabel

這個範例突顯了一個基本的能力缺口。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
$vbLabelText   $csharpLabel

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
$vbLabelText   $csharpLabel

本範例展示了最顯著的能力差異。 Pdfium 明確指出:"Pdfium.NET 不支援 HTML 至 PDF 的轉換",以及 "您需要使用單獨的函式庫來轉換 HTML 至 PDF"。

IronPDF 透過 ChromePdfRenderer 提供原生 HTML 到 PDF 的轉換,它內部使用 Chromium 引擎來精確渲染 HTML、CSS 和 JavaScript。 RenderHtmlAsPdf() 方法直接將 HTML 字串轉換為 PDF 文件。IronPDF也可以渲染帶有 RenderUrlAsPdf() 的 URL 和帶有 RenderHtmlFileAsPdf() 的 HTML 檔案。 請參閱 HTML to 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

After (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
SHELL

關鍵遷移注意事項

縮放至 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)
$vbLabelText   $csharpLabel

文件載入方法變更

// Pdfium
PdfDocument.Load(path)

// IronPDF
PdfDocument.FromFile(path)
// Pdfium
PdfDocument.Load(path)

// IronPDF
PdfDocument.FromFile(path)
$vbLabelText   $csharpLabel

儲存方法變更

// Pdfium
document.Save(path)

// IronPDF
pdf.SaveAs(path)
// Pdfium
document.Save(path)

// IronPDF
pdf.SaveAs(path)
$vbLabelText   $csharpLabel

處理模式簡化

// 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")
$vbLabelText   $csharpLabel

移除特定平台的程式碼

// 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
$vbLabelText   $csharpLabel

功能比較摘要

特點 Pdfium.NET IronPDF
載入 PDF
渲染至圖片
擷取文字 ✓(基本) ✓(進階)
頁面資訊
從 HTML 建立
從 URL 建立
合併 PDF
分割 PDF
添加水印
頁首/頁尾
表格填寫
數位簽名
密碼保護
本地相依性 要求
跨平台 複雜的 自動化
記憶體管理 手冊處理 簡化

遷移清單

預遷移

  • 識別程式碼庫中所有 Pdfium 的使用情況
  • 記錄目前使用的渲染尺寸/比例
  • 列出專案中的本機二進位位置
  • 檢查平台特定的載入程式碼
  • 確定PDF創建需求(目前是否使用不同的工具?)
  • 審查轉換處置模式
  • 取得IronPDF許可證密鑰

套件變更

  • 刪除 Pdfium.NETPdfium.Net.SDKPdfiumViewer NuGet 套件
  • 從 x86/、x64/ 和 runtimes/ 資料夾中刪除本機 pdfium.dll 二進位文件
  • 移除平台特定的條件編譯
  • 更新 .csproj 檔案以移除原生二進位引用 安裝 IronPdf NuGet 套件:dotnet add package IronPdf

程式碼變更

  • 在啟動時新增許可證金鑰配置
  • PdfDocument.Load() 替換為 PdfDocument.FromFile()
  • document.Save() 替換為 pdf.SaveAs()
  • document.GetPdfText(i) 迴圈替換為 pdf.ExtractAllText()
  • 將比例因子轉換為 DPI 值(DPI = 72 × 比例)
  • 簡化資源釋放模式(移除巢狀的 using 語句)
  • 刪除平台特定程式碼

後遷移

  • 測試渲染輸出質量
  • 比較文字擷取結果
  • 測試跨平台部署
  • 新增功能(HTML 轉 PDF、合併、浮水印、安全)
  • 更新文件

Curtis Chau
技術作家

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

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

鋼鐵支援團隊

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