跳至頁尾內容
影片

如何使用 C# 將 SVG 轉換為 PDF

從PDFreactor遷移到IronPDF,消除了Java依賴和伺服器基礎設施,同時通過原生.NET程式庫提供等效的HTML到PDF轉換功能。 本指南提供了一個完整的、逐步的遷移路徑,將您的基於Java的伺服器架構替換為可以無縫整合到.NET應用程式中的進程內程式庫。

為什麼從PDFreactor遷移到IronPDF

了解PDFreactor

PDFreactor是一個強大的HTML到PDF轉換伺服器,能夠跨多種平台進行整合。 作為商業解決方案,PDFreactor利用其專有技術將HTML和CSS內容轉換為高品質的PDF文件。 PDFreactor的顯著特點之一是支持多樣的CSS屬性,使其成為複雜佈局渲染的有力候選者。

然而,PDFreactor對Java的依賴在.NET環境中帶來了一些挑戰,因其非原生特性可能使部署和整合變得複雜。 其對Java的依賴會在.NET應用中增加額外的負擔,通常需要額外的整合工作。

Java依賴問題

PDFreactor的架構在.NET環境中帶來了幾個挑戰:

  1. 需要Java運行時: 需要在所有伺服器上安裝JRE/JDK。

  2. 伺服器架構: 作為單獨的服務運行,需額外的基礎設施。 作為基於伺服器的解決方案,PDFreactor要求每次轉換都進行REST API調用。

  3. 複雜部署: 在以.NET為主的生態系統中管理Java依賴可能使設置複雜化並增加維護成本。 需要管理兩個運行時(Java + .NET)在CI/CD管道中。

  4. 進程間通信: REST API或socket通信會增加延遲。 每次PDF轉換都需要HTTP往返到伺服器。

  5. 單獨授權管理: 授權綁定到伺服器實例,而非應用程式。 每個伺服器授權綁定到Java服務實例。

  6. 資源隔離: 單獨的進程記憶體和CPU管理。 需要額外的伺服器進行監控、擴展和維護。

PDFreactor與IronPDF比較

特徵/方面 PDFreactor IronPDF
原生.NET程式庫 否(Java-based)
運行時 Java(外部伺服器) 原生.NET(進程內)
架構 REST API服務 NuGet程式庫
部署 Java + 伺服器配置 單個NuGet套件
依賴關係 JRE + HTTP客戶端 自包含
延遲 網路往返 直接方法調用
跨平台能力 是(Java依賴) 是(捆綁的Chromium)
CSS 支援 對CSS3、CSS Paged Media的高級支持 全面支持HTML5/CSS3
部署複雜性 由於Java更為複雜 簡單,直接與.NET整合
PDF操作功能 基本(僅生成) 廣泛,包括合併、拆分、編輯和註釋

與PDFreactor相比,IronPDF作為.NET原生程式庫呈現,專門設計為無需外部依賴如Java即可無縫整合到.NET專案中。 IronPDF使用捆綁的Chromium渲染引擎,使其能夠用簡短的程式碼將HTML轉換為PDF。

對於採用現代.NET版本的團隊,IronPDF提供了消除Java伺服器複雜性的原生.NET解決方案,同時提供全面的PDF生命周期管理。


開始之前

前提條件

  1. .NET環境:.NET Framework 4.6.2+ 或.NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGet存取: 有能力安裝NuGet套件
  3. IronPDF授權:ironpdf.com獲取您的授權金鑰

NuGet包變更

#PDFreactoris NOT distributed via NuGet. The .NET wrapper ships as
# PDFreactor.dll inside <PDFreactor-install>/clients/netstandard2/bin/
# (or netframework40/bin for older .NET Framework projects).
# Remove the assembly reference from your .csproj.

# StopPDFreactorWeb Service (Java/Jetty, default port 9423)
# Windows: net stop PDFreactor
# Linux:   sudo systemctl stop pdfreactor

# Install IronPDF
dotnet add package IronPdf
#PDFreactoris NOT distributed via NuGet. The .NET wrapper ships as
# PDFreactor.dll inside <PDFreactor-install>/clients/netstandard2/bin/
# (or netframework40/bin for older .NET Framework projects).
# Remove the assembly reference from your .csproj.

# StopPDFreactorWeb Service (Java/Jetty, default port 9423)
# Windows: net stop PDFreactor
# Linux:   sudo systemctl stop pdfreactor

# Install IronPDF
dotnet add package IronPdf
SHELL

授權配置

PDFreactor(基於伺服器):

// License configured on thePDFreactorWeb Service via config file or command line.
// The .NET client (RealObjects.PDFreactor.Webservice.Client) connects to that licensed service.
var pdfReactor = new PDFreactor("http://pdfreactor-server:9423/service/rest");
// License configured on thePDFreactorWeb Service via config file or command line.
// The .NET client (RealObjects.PDFreactor.Webservice.Client) connects to that licensed service.
var pdfReactor = new PDFreactor("http://pdfreactor-server:9423/service/rest");
' License configured on thePDFreactorWeb Service via config file or command line.
' The .NET client (RealObjects.PDFreactor.Webservice.Client) connects to that licensed service.
Dim pdfReactor = New PDFreactor("http://pdfreactor-server:9423/service/rest")
$vbLabelText   $csharpLabel

IronPDF(應用程式層):

// One-time setup at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
// One-time setup at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
' One-time setup at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"
$vbLabelText   $csharpLabel

識別PDFreactor使用情況

# FindPDFreactorusage
grep -r "PDFreactor\|RealObjects\|Configuration.*Document" --include="*.cs" .

# FindCSS Paged Mediarules to convert
grep -r "@page\|counter(page)\|counter(pages)" --include="*.cs" --include="*.css" .
# FindPDFreactorusage
grep -r "PDFreactor\|RealObjects\|Configuration.*Document" --include="*.cs" .

# FindCSS Paged Mediarules to convert
grep -r "@page\|counter(page)\|counter(pages)" --include="*.cs" --include="*.css" .
SHELL

完整API參考

名稱空間變更

// Before:PDFreactor(Web Service client)
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
// Before:PDFreactor(Web Service client)
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
Imports RealObjects.PDFreactor.Webservice.Client
Imports System.IO

' After: IronPDF
Imports IronPdf
Imports IronPdf.Rendering
$vbLabelText   $csharpLabel

核心類別映射

PDFreactor IronPDF
PDFreactor ChromePdfRenderer
Configuration ChromePdfRenderOptions
Result PdfDocument
config.Document = html renderer.RenderHtmlAsPdf(html)
result.Document(byte[]) pdf.BinaryData

配置屬性映射

PDFreactor配置 IronPDF RenderingOptions
config.Document = html renderer.RenderHtmlAsPdf(html)
config.Document = url renderer.RenderUrlAsPdf(url)
config.PageFormat = PageFormat.A4 RenderingOptions.PaperSize = PdfPaperSize.A4
config.PageOrientation RenderingOptions.PaperOrientation
config.PageMargins RenderingOptions.MarginTop/Bottom/Left/Right
config.EnableJavaScript = true RenderingOptions.EnableJavaScript = true
config.UserStyleSheets = new List<Resource>{...} 在HTML中嵌入CSS
config.Title pdf.MetaData.Title
config.Encryption pdf.SecuritySettings

PDFreactor中未提供的新功能

IronPDF功能 說明
PdfDocument.Merge() 合併多個PDF
pdf.ApplyWatermark() 新增水印
pdf.ExtractAllText() 文字提取
pdf.Form 表單填寫
pdf.Sign() 數位簽名

程式碼遷移範例

範例1:HTML字串轉PDF

之前(PDFreactor):

//PDFreactor.NET wrapper is a Web Service client (no NuGet package).
// Reference PDFreactor.dll from <PDFreactor-install>/clients/netstandard2/bin/
// and run thePDFreactorWeb Service (Java/Jetty) locally or remotely.
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

class Program
{
    static void Main()
    {
       PDFreactorpdfReactor = new PDFreactor();

        string html = "<html><body><h1>Hello World</h1></body></html>";

        Configuration config = new Configuration();
        config.Document = html;

        Result result = pdfReactor.Convert(config);

        File.WriteAllBytes("output.pdf", result.Document);
    }
}
//PDFreactor.NET wrapper is a Web Service client (no NuGet package).
// Reference PDFreactor.dll from <PDFreactor-install>/clients/netstandard2/bin/
// and run thePDFreactorWeb Service (Java/Jetty) locally or remotely.
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

class Program
{
    static void Main()
    {
       PDFreactorpdfReactor = new PDFreactor();

        string html = "<html><body><h1>Hello World</h1></body></html>";

        Configuration config = new Configuration();
        config.Document = html;

        Result result = pdfReactor.Convert(config);

        File.WriteAllBytes("output.pdf", result.Document);
    }
}
Imports RealObjects.PDFreactor.Webservice.Client
Imports System.IO

Class Program
    Shared Sub Main()
        Dim pdfReactor As New PDFreactor()

        Dim html As String = "<html><body><h1>Hello World</h1></body></html>"

        Dim config As New Configuration()
        config.Document = html

        Dim result As Result = pdfReactor.Convert(config)

        File.WriteAllBytes("output.pdf", result.Document)
    End Sub
End Class
$vbLabelText   $csharpLabel

之後(IronPDF):

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

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

        string html = "<html><body><h1>Hello World</h1></body></html>";

        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 = "<html><body><h1>Hello World</h1></body></html>";

        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 = "<html><body><h1>Hello World</h1></body></html>"

        Dim pdf = renderer.RenderHtmlAsPdf(html)

        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

基本的區別在於架構模式。 PDFreactor需要建立一個result.Document字節寫入文件。

IronPDF將其簡化為建立一個SaveAs()方法。 無需伺服器連接,無需配置物件,無需手動字節處理。 查看更多HTML到PDF文件以獲得完整的範例。

範例2:URL轉PDF轉換

之前(PDFreactor):

//PDFreactor.NET wrapper is a Web Service client (no NuGet package).
// Reference PDFreactor.dll from <PDFreactor-install>/clients/netstandard2/bin/
// and run thePDFreactorWeb Service (Java/Jetty) locally or remotely.
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

class Program
{
    static void Main()
    {
       PDFreactorpdfReactor = new PDFreactor();

        Configuration config = new Configuration();
        config.Document = "https://www.example.com";

        Result result = pdfReactor.Convert(config);

        File.WriteAllBytes("webpage.pdf", result.Document);
    }
}
//PDFreactor.NET wrapper is a Web Service client (no NuGet package).
// Reference PDFreactor.dll from <PDFreactor-install>/clients/netstandard2/bin/
// and run thePDFreactorWeb Service (Java/Jetty) locally or remotely.
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

class Program
{
    static void Main()
    {
       PDFreactorpdfReactor = new PDFreactor();

        Configuration config = new Configuration();
        config.Document = "https://www.example.com";

        Result result = pdfReactor.Convert(config);

        File.WriteAllBytes("webpage.pdf", result.Document);
    }
}
Imports RealObjects.PDFreactor.Webservice.Client
Imports System.IO

Class Program
    Shared Sub Main()
        Dim pdfReactor As New PDFreactor()

        Dim config As New Configuration()
        config.Document = "https://www.example.com"

        Dim result As Result = pdfReactor.Convert(config)

        File.WriteAllBytes("webpage.pdf", result.Document)
    End Sub
End Class
$vbLabelText   $csharpLabel

之後(IronPDF):

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

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

        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");

        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

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

        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");

        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf
Imports System

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

        Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")

        pdf.SaveAs("webpage.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

PDFreactor對相同的config.Document屬性適用於HTML字串和URL,並自動判斷型別。 IronPDF提供明確的方法:RenderHtmlAsPdf() 適用於HTML字串和RenderUrlAsPdf()適用於URL。 這種明確的方法改善了程式碼的清晰度和IntelliSense支持。 在我們的教程中了解更多。

範例3:具有頁碼的標頭和頁腳

之前(PDFreactor):

//PDFreactor.NET wrapper is a Web Service client (no NuGet package).
// Reference PDFreactor.dll from <PDFreactor-install>/clients/netstandard2/bin/
// and run thePDFreactorWeb Service (Java/Jetty) locally or remotely.
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

class Program
{
    static void Main()
    {
       PDFreactorpdfReactor = new PDFreactor();

        string html = "<html><body><h1>Document with Headers</h1><p>Content here</p></body></html>";

        Configuration config = new Configuration();
        config.Document = html;
        config.UserStyleSheets = new System.Collections.Generic.List<Resource>
        {
            new Resource { Content = "@page { @top-center { content: 'Header Text'; } @bottom-center { content: 'Page ' counter(page); } }" }
        };

        Result result = pdfReactor.Convert(config);

        File.WriteAllBytes("document.pdf", result.Document);
    }
}
//PDFreactor.NET wrapper is a Web Service client (no NuGet package).
// Reference PDFreactor.dll from <PDFreactor-install>/clients/netstandard2/bin/
// and run thePDFreactorWeb Service (Java/Jetty) locally or remotely.
using RealObjects.PDFreactor.Webservice.Client;
using System.IO;

class Program
{
    static void Main()
    {
       PDFreactorpdfReactor = new PDFreactor();

        string html = "<html><body><h1>Document with Headers</h1><p>Content here</p></body></html>";

        Configuration config = new Configuration();
        config.Document = html;
        config.UserStyleSheets = new System.Collections.Generic.List<Resource>
        {
            new Resource { Content = "@page { @top-center { content: 'Header Text'; } @bottom-center { content: 'Page ' counter(page); } }" }
        };

        Result result = pdfReactor.Convert(config);

        File.WriteAllBytes("document.pdf", result.Document);
    }
}
Imports RealObjects.PDFreactor.Webservice.Client
Imports System.IO

Class Program
    Shared Sub Main()
        Dim pdfReactor As New PDFreactor()

        Dim html As String = "<html><body><h1>Document with Headers</h1><p>Content here</p></body></html>"

        Dim config As New Configuration()
        config.Document = html
        config.UserStyleSheets = New System.Collections.Generic.List(Of Resource) From {
            New Resource With {.Content = "@page { @top-center { content: 'Header Text'; } @bottom-center { content: 'Page ' counter(page); } }"}
        }

        Dim result As Result = pdfReactor.Convert(config)

        File.WriteAllBytes("document.pdf", result.Document)
    End Sub
End Class
$vbLabelText   $csharpLabel

之後(IronPDF):

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

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

        renderer.RenderingOptions.TextHeader = new TextHeaderFooter()
        {
            CenterText = "Header Text"
        };

        renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
        {
            CenterText = "Page {page}"
        };

        string html = "<html><body><h1>Document with Headers</h1><p>Content here</p></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("document.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;

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

        renderer.RenderingOptions.TextHeader = new TextHeaderFooter()
        {
            CenterText = "Header Text"
        };

        renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
        {
            CenterText = "Page {page}"
        };

        string html = "<html><body><h1>Document with Headers</h1><p>Content here</p></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("document.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Rendering
Imports System

Module Program
    Sub Main()
        Dim renderer As New ChromePdfRenderer()

        renderer.RenderingOptions.TextHeader = New TextHeaderFooter() With {
            .CenterText = "Header Text"
        }

        renderer.RenderingOptions.TextFooter = New TextHeaderFooter() With {
            .CenterText = "Page {page}"
        }

        Dim html As String = "<html><body><h1>Document with Headers</h1><p>Content here</p></body></html>"

        Dim pdf = renderer.RenderHtmlAsPdf(html)

        pdf.SaveAs("document.pdf")
    End Sub
End Module
$vbLabelText   $csharpLabel

此範例顯示了最顯著的語法差異。 PDFreactor使用CSS Paged Media語法的counter(page)頁碼。

IronPDF使用原生.NET API,將RenderingOptions.TextFooter。 頁碼使用{page}佔位符,而不是CSS counter(page)


關鍵遷移注意事項

不需伺服器

IronPDF運行於進程中——無需配置Java伺服器。

// PDFreactor: Requires the Web Service running on a reachable host
var pdfReactor = new PDFreactor("http://localhost:9423/service/rest");

// IronPDF: No server URL needed
var renderer = new ChromePdfRenderer();
// PDFreactor: Requires the Web Service running on a reachable host
var pdfReactor = new PDFreactor("http://localhost:9423/service/rest");

// IronPDF: No server URL needed
var renderer = new ChromePdfRenderer();
' PDFreactor: Requires the Web Service running on a reachable host
Dim pdfReactor = New PDFreactor("http://localhost:9423/service/rest")

' IronPDF: No server URL needed
Dim renderer = New ChromePdfRenderer()
$vbLabelText   $csharpLabel

CSS Paged Media轉換到IronPDF API

用RenderingOptions替換CSS @page規則。

//PDFreactorCSS: @page { @bottom-center { content: 'Page ' counter(page); } }
//IronPDFequivalent:
renderer.RenderingOptions.TextFooter = new TextHeaderFooter 
{ 
    CenterText = "Page {page}" 
};
//PDFreactorCSS: @page { @bottom-center { content: 'Page ' counter(page); } }
//IronPDFequivalent:
renderer.RenderingOptions.TextFooter = new TextHeaderFooter 
{ 
    CenterText = "Page {page}" 
};
'PDFreactorCSS: @page { @bottom-center { content: 'Page ' counter(page); } }
'IronPDFequivalent:
renderer.RenderingOptions.TextFooter = New TextHeaderFooter With {
    .CenterText = "Page {page}"
}
$vbLabelText   $csharpLabel

頁數占位符語法

//PDFreactorCSS: counter(page)
// IronPDF: {page}

//PDFreactorCSS: counter(pages)  
// IronPDF: {total-pages}
//PDFreactorCSS: counter(page)
// IronPDF: {page}

//PDFreactorCSS: counter(pages)  
// IronPDF: {total-pages}
'PDFreactorCSS: counter(page)
' IronPDF: {page}

'PDFreactorCSS: counter(pages)  
' IronPDF: {total-pages}
$vbLabelText   $csharpLabel

結果處理變更

配置+結果模式變為直接PdfDocument。

// PDFreactor: Configuration → Convert → Result → bytes
Result result = pdfReactor.Convert(config);
byte[] bytes = result.Document;
File.WriteAllBytes("output.pdf", bytes);

// IronPDF: Direct PdfDocument with built-in methods
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
// Or: byte[] bytes = pdf.BinaryData;
// PDFreactor: Configuration → Convert → Result → bytes
Result result = pdfReactor.Convert(config);
byte[] bytes = result.Document;
File.WriteAllBytes("output.pdf", bytes);

// IronPDF: Direct PdfDocument with built-in methods
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
// Or: byte[] bytes = pdf.BinaryData;
' PDFreactor: Configuration → Convert → Result → bytes
Dim result As Result = pdfReactor.Convert(config)
Dim bytes As Byte() = result.Document
File.WriteAllBytes("output.pdf", bytes)

' IronPDF: Direct PdfDocument with built-in methods
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
' Or: Dim bytes As Byte() = pdf.BinaryData
$vbLabelText   $csharpLabel

邊距單位更改

PDFreactor使用字串; IronPDF使用毫米:

// PDFreactor: config.PageMargins.Top = "1in"
// IronPDF: renderer.RenderingOptions.MarginTop = 25.4  // 1 inch in mm
// PDFreactor: config.PageMargins.Top = "1in"
// IronPDF: renderer.RenderingOptions.MarginTop = 25.4  // 1 inch in mm
' PDFreactor: config.PageMargins.Top = "1in"
' IronPDF: renderer.RenderingOptions.MarginTop = 25.4  ' 1 inch in mm
$vbLabelText   $csharpLabel

遷移後的新能力

遷移到IronPDF後,您將獲得PDFreactor無法提供的功能:

PDF合併

var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged.pdf");
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
merged.SaveAs("merged.pdf")
$vbLabelText   $csharpLabel

水印

pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>");
pdf.ApplyWatermark("<h2 style='color:red;'>CONFIDENTIAL</h2>")
$vbLabelText   $csharpLabel

文字提取

string text = pdf.ExtractAllText();
string text = pdf.ExtractAllText();
Dim text As String = pdf.ExtractAllText()
$vbLabelText   $csharpLabel

密碼保護

pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword";
pdf.SecuritySettings.OwnerPassword = "ownerpassword";
pdf.SecuritySettings.UserPassword = "userpassword"
pdf.SecuritySettings.OwnerPassword = "ownerpassword"
$vbLabelText   $csharpLabel

功能比較總結

功能 PDFreactor IronPDF
HTML轉PDF
URL到PDF
頁眉/頁腳 CSS Paged Media 原生API
頁面設置
JavaScript支持
原生.NET
進程內
合併PDF
拆分PDF
浮水印
文字提取
表單填寫
數位簽名

遷移檢查表

遷移前

  • 清查所有程式碼庫中的PDFreactor使用
  • 記錄所有已使用的CSS Paged Media規則
  • 記錄所有配置設置(邊距、頁面大小、JavaScript)
  • 規劃IronPDF授權密鑰的儲存(建議使用環境變數)
  • 先使用IronPDF試用授權進行測試

套件變更

  • 從您的PDFreactor.dll程式集參考
  • 退役PDFreactor Web服務(Java/Jetty)
  • 安裝dotnet add package IronPdf

程式碼變更

  • 更新命名空間導入(using IronPdf;)
  • 新增using IronPdf.Rendering;用於標題/頁腳類
  • PDFreactor
  • RenderingOptions屬性
  • renderer.RenderHtmlAsPdf(html)
  • renderer.RenderUrlAsPdf(url)
  • pdf.SaveAs(path)
  • 將CSS TextFooter物件
  • 更新頁碼佔位符({page})
  • 將邊距單位從字串轉為毫米

基礎設施遷移

  • 去除Java運行時要求
  • 退役PDFreactor伺服器
  • 更新Docker/部署配置
  • 更新 CI/CD 管道

遷移後

  • 測試PDF輸出質量是否符合預期
  • 驗證頁眉/頁腳的渲染
  • 如果使用,驗證JavaScript執行
  • 根據需要新增新功能(合併,水印,安全性)

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

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

Iron 支援團隊

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