比較

Haukcode.DinkToPdf與IronPDF:技術比較指南

當.NET開發者需要將URL和HTML內容轉換為PDF時,他們面臨一個重要的架構決策:使用像PDFmyURL這樣的雲端API服務還是選擇像IronPDF這樣的本地處理程式庫。 本比較探討兩種選擇,著重於其技術差異、隱私考量以及適合各種應用程式需求的情況。

什麼是PDFmyURL?

PDFmyURL是一個專為將URL和HTML轉換為PDF而設計的雲端API服務。 該服務在外部伺服器上處理文件。 對於.NET整合,PDFmyURL提供了一個可下載的DLL元件(PDFmyURL類別。 此元件包裝了雲端API,將內容發送到PDFmyURL的伺服器進行渲染。

該服務重視易用性,並提供符合W3C標準的一致渲染。 然而,每次轉換都需要網際網路連接,並將文件內容發送到外部伺服器進行處理。

PDFmyURL的主要功能包括:

  • 雲端處理:所有轉換均在PDFmyURL的外部伺服器上進行。
  • 訂閱定價:起價為每月39美元,並有持續性費用。
  • 網路依賴性:每次轉換都需要網路連接。
  • 授權金鑰認證:需要.NET元件的授權金鑰。
  • 速率限制:API呼叫可根據訂閱計劃進行節流。

什麼是 IronPDF?

IronPDF是一個完整的.NET程式庫,在您的應用程式環境中本地處理PDF。 ChromePdfRenderer類別使用現代的以Chromium為基礎的引擎進行HTML到PDF的轉換,提供完整的CSS3和JavaScript支持,無需將資料發送到外部伺服器。

與PDFmyURL的雲端方法不同,IronPDF在您的基礎設施內部處理一切。 此設置消除了與外部處理相關的隱私問題,同時提供了超出基本轉換能力的功能——包括PDF操作、文字提取、水印和安全功能。

架構比較

PDFmyURL和IronPDF的主要區別在於處理位置:外部伺服器與本地處理。

方面PDFmyURLIronPDF
型別API包裝器.NET程式庫
處理位置外部伺服器本地(您的伺服器)
依賴性需要網際網路連接本地處理
認證每次請求API金鑰單次授權金鑰
成本每月39美元以上的訂閱可用永久授權
隱私資料外送資料保留本地
速率限制是的(取決於計劃)None
平台支持基於網路跨平台
使用案例低容量應用程式高容量和企業

對於處理敏感文件的應用程式——合同、財務報告、個人資料——處理位置會對隱私和合規性產生重大影響。 PDFmyURL將所有文件路由至外部伺服器,而IronPDF則將所有文件保留在您的控制環境中。

URL 轉 PDF

將網頁轉換為PDF突出了這些解決方案之間的API模式差異。

PDFmyURL URL到PDF的方法:

// Download PDFmyURL.NET.dll from pdfmyurl.com
using System;
using PDFmyURLdotNET;

class Example
{
    static void Main()
    {
        try
        {
            var pdf = new PDFmyURL("your-license-key");
            pdf.ConvertURL("https://example.com", "output.pdf");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
// Download PDFmyURL.NET.dll from pdfmyurl.com
using System;
using PDFmyURLdotNET;

class Example
{
    static void Main()
    {
        try
        {
            var pdf = new PDFmyURL("your-license-key");
            pdf.ConvertURL("https://example.com", "output.pdf");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
Imports System
Imports PDFmyURLdotNET

Class Example
    Shared Sub Main()
        Try
            Dim pdf = New PDFmyURL("your-license-key")
            pdf.ConvertURL("https://example.com", "output.pdf")
        Catch ex As Exception
            Console.WriteLine("Error: " & ex.Message)
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF URL到PDF方法:

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

class Example
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Example
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://example.com");
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System

Class Example
    Shared Sub Main()
        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

PDFmyURL需要授權金鑰並將URL發送到其雲端伺服器進行渲染。 ConvertURL()處理雲端往返。

IronPDF的PdfDocument物件。 在IronPDF文件中了解更多關於URL到PDF轉換的資訊。

HTML字串到PDF轉換

直接將HTML內容轉換為PDF顯示出類似的架構差異。

PDFmyURL HTML字串轉換:

// Download PDFmyURL.NET.dll from pdfmyurl.com
using System;
using PDFmyURLdotNET;

class Example
{
    static void Main()
    {
        try
        {
            var pdf = new PDFmyURL("your-license-key");
            string html = "<html><body><h1>Hello World</h1></body></html>";
            pdf.ConvertHTML(html, "output.pdf");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
// Download PDFmyURL.NET.dll from pdfmyurl.com
using System;
using PDFmyURLdotNET;

class Example
{
    static void Main()
    {
        try
        {
            var pdf = new PDFmyURL("your-license-key");
            string html = "<html><body><h1>Hello World</h1></body></html>";
            pdf.ConvertHTML(html, "output.pdf");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
Imports System
Imports PDFmyURLdotNET

Module Example
    Sub Main()
        Try
            Dim pdf = New PDFmyURL("your-license-key")
            Dim html As String = "<html><body><h1>Hello World</h1></body></html>"
            pdf.ConvertHTML(html, "output.pdf")
        Catch ex As Exception
            Console.WriteLine("Error: " & ex.Message)
        End Try
    End Sub
End Module
$vbLabelText   $csharpLabel

IronPDF HTML字串轉換:

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

class Example
{
    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 Example
{
    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 Example
    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

使用PDFmyURL,HTML內容通過ConvertHTML()傳送到外部伺服器。 這意味著您的HTML模板、動態內容和任何嵌入的資料都會通過第三方基礎設施。

IronPDF的RenderHtmlAsPdf()在本地處理HTML,保持內容在你的應用程式範圍內。 有關HTML到PDF轉換模式的詳細指南,請參閱HTML到PDF教程

HTML文件轉換設置

配置頁面設置揭示了兩種解決方案之間的不同API設計模式。

PDFmyURL文件轉換設置:

// Download PDFmyURL.NET.dll from pdfmyurl.com
using System;
using System.IO;
using PDFmyURLdotNET;

class Example
{
    static void Main()
    {
        try
        {
            var pdf = new PDFmyURL("your-license-key");
            pdf.PageSize = "A4";
            pdf.PageOrientation = "landscape";
            pdf.Margins = "10 10 10 10";
            var htmlContent = File.ReadAllText("input.html");
            pdf.ConvertHTML(htmlContent, "output.pdf");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
// Download PDFmyURL.NET.dll from pdfmyurl.com
using System;
using System.IO;
using PDFmyURLdotNET;

class Example
{
    static void Main()
    {
        try
        {
            var pdf = new PDFmyURL("your-license-key");
            pdf.PageSize = "A4";
            pdf.PageOrientation = "landscape";
            pdf.Margins = "10 10 10 10";
            var htmlContent = File.ReadAllText("input.html");
            pdf.ConvertHTML(htmlContent, "output.pdf");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex.Message);
        }
    }
}
Imports System
Imports System.IO
Imports PDFmyURLdotNET

Class Example
    Shared Sub Main()
        Try
            Dim pdf = New PDFmyURL("your-license-key")
            pdf.PageSize = "A4"
            pdf.PageOrientation = "landscape"
            pdf.Margins = "10 10 10 10"
            Dim htmlContent = File.ReadAllText("input.html")
            pdf.ConvertHTML(htmlContent, "output.pdf")
        Catch ex As Exception
            Console.WriteLine("Error: " & ex.Message)
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF文件轉換設置:

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

class Example
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
        renderer.RenderingOptions.MarginTop = 10;
        var pdf = renderer.RenderHtmlFileAsPdf("input.html");
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;

class Example
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
        renderer.RenderingOptions.MarginTop = 10;
        var pdf = renderer.RenderHtmlFileAsPdf("input.html");
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Rendering
Imports System

Class Example
    Shared Sub Main()
        Dim renderer As New ChromePdfRenderer()
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape
        renderer.RenderingOptions.MarginTop = 10
        Dim pdf = renderer.RenderHtmlFileAsPdf("input.html")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

PDFmyURL在Margins)。 該元件沒有專門的文件轉換方法,因此HTML文件必須先用File.ReadAllText()讀取。

IronPDF通過RenderingOptions物件使用強型別屬性。 PdfPaperOrientation.Landscape是提供IntelliSense支持和編譯時驗證的枚舉值。 邊距值是數字(以毫米為單位),而不是帶有單位後綴的字串。

API映射參考

對於那些評估從PDFmyURL遷移到IronPDF的團隊,了解API映射有助於估算開發努力。

核心方法

PDFmyURL (.NET元件)IronPDF
new PDFmyURL("licenseKey")new ChromePdfRenderer()
pdf.ConvertURL(url, file)renderer.RenderUrlAsPdf(url).SaveAs(file)
pdf.ConvertHTML(html, file)renderer.RenderHtmlAsPdf(html).SaveAs(file)
讀取文件 + pdf.ConvertHTML(content, file)renderer.RenderHtmlFileAsPdf(input).SaveAs(output)

配置選項

PDFmyURLIronPDF
pdf.PageSize = "A4"RenderingOptions.PaperSize = PdfPaperSize.A4
pdf.PageOrientation = "landscape"RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape
pdf.Margins = "10 10 10 10"RenderingOptions.MarginTop/Bottom/Left/Right = 10
pdf.Header = htmlRenderingOptions.HtmlHeader = new HtmlHeaderFooter { HtmlFragment = html }
pdf.Footer = htmlRenderingOptions.HtmlFooter = new HtmlHeaderFooter { HtmlFragment = html }
pdf.JavaScriptDelay = 500RenderingOptions.RenderDelay = 500
pdf.CssMediaType = "print"RenderingOptions.CssMediaType = PdfCssMediaType.Print
pdf.UserPassword = "pass"pdf.SecuritySettings.UserPassword = "pass"

PDFmyURL中不可用的功能

IronPDF功能描述
PdfDocument.Merge()合併多個PDF
pdf.ExtractAllText()提取文字內容
pdf.ApplyWatermark()新增水印
pdf.SecuritySettings密碼保護和加密
pdf.Form表單填寫和操作
pdf.Sign()數位簽名

IronPDF中的這些額外功能超越了基本轉換,提供了完整的PDF生命週期管理。 有關PDF操作功能,請參閱合併和拆分PDF指導

隱私和資料安全性

處理位置差異對資料處理有重要影響。

PDFmyURL隱私考量:

  • 每份文件都經過外部伺服器。
  • 敏感合同、財務報告和個人資料在外部處理。
  • 無法控制在第三方基礎設施上的資料保留。
  • 合規要求可能禁止外部處理。

IronPDF隱私優勢:

  • 文件從未離開您的伺服器。
  • 完全控制資料處理。
  • 適用於受監管行業(醫療保健、金融、法律)。
  • 無第三方資料曝光。

對於處理敏感資訊或在合規要求下運行的組織(GDPR、HIPAA、SOC 2),本地處理消除了評估第三方資料處理實踐的複雜性。

成本結構比較

兩者的定價模式在訂閱和永久授權上存在根本差異。

價格方面PDFmyURLIronPDF
模式每月訂閱可用永久授權
啟動成本每月39美元一次性購買
年度成本每年468美元以上無需持續性費用
速率限制取決於計劃None
容量擴展需要更高的層級無限制處理

對於長期項目或高容量應用程式來說,PDFmyURL的訂閱模式在時間上會累積大量成本。IronPDF的永久授權選項提供了可預測的經濟效益,無需持續性費用或容量限制。

認證模式

兩者在認證方法上有顯著差異。

PDFmyURL認證:

// License key required for the .NET component
var pdf = new PDFmyURL("your-license-key");
// License key required for the .NET component
var pdf = new PDFmyURL("your-license-key");
' License key required for the .NET component
Dim pdf = New PDFmyURL("your-license-key")
$vbLabelText   $csharpLabel

IronPDF認證:

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

PDFmyURL需要每個PDFmyURL物件實例化的授權金鑰。 IronPDF的授權金鑰在應用程式啟動時設置,通常在配置中,消除每個實例的憑證處理。

頁眉和頁腳佔位符語法

從PDFmyURL遷移的團隊應注意動態頁眉和頁腳的佔位符語法差異。

PDFmyURL佔位符:

pdf.Header = "<div>Page header content</div>";
pdf.Footer = "<div>Page footer content</div>";
pdf.Header = "<div>Page header content</div>";
pdf.Footer = "<div>Page footer content</div>";
pdf.Header = "<div>Page header content</div>"
pdf.Footer = "<div>Page footer content</div>"
$vbLabelText   $csharpLabel

IronPDF佔位符:

renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
    HtmlFragment = "<div>Page {page} of {total-pages}</div>"
};
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
    HtmlFragment = "<div>Page {page} of {total-pages}</div>"
};
Imports System

renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter With {
    .HtmlFragment = "<div>Page {page} of {total-pages}</div>"
}
$vbLabelText   $csharpLabel

PDFmyURL通過Footer屬性支持頁眉和頁腳中的HTML內容。 IronPDF使用{total-pages}佔位符來進行動態頁碼。 有關全面的頁眉和頁腳實施,請參閱頁眉和頁腳文件

異步模式差異

兩者在處理異步操作上的方法不同。

PDFmyURL異步:

// PDFmyURL: Event-based async via DownloadCompleted handler
var pdf = new PDFmyURL("your-license-key");
pdf.DownloadCompleted += (s, e) => { /* handle completed PDF */ };
pdf.ConvertURL("https://example.com", "output.pdf", true); // async = true
// PDFmyURL: Event-based async via DownloadCompleted handler
var pdf = new PDFmyURL("your-license-key");
pdf.DownloadCompleted += (s, e) => { /* handle completed PDF */ };
pdf.ConvertURL("https://example.com", "output.pdf", true); // async = true
Imports PDFmyURLNamespace

Dim pdf As New PDFmyURL("your-license-key")
AddHandler pdf.DownloadCompleted, Sub(s, e)
    ' handle completed PDF
End Sub
pdf.ConvertURL("https://example.com", "output.pdf", True) ' async = true
$vbLabelText   $csharpLabel

IronPDF異步:

// IronPDF: Sync by default, wrap for async
var pdf = await Task.Run(() => renderer.RenderUrlAsPdf(url));
// IronPDF: Sync by default, wrap for async
var pdf = await Task.Run(() => renderer.RenderUrlAsPdf(url));
$vbLabelText   $csharpLabel

PDFmyURL通過ConvertHTML()中的異步參數傳遞。 IronPDF操作預設是同步的,但可以包裝在Task.Run()中以用于異步上下文。

錯誤處理

解決方案之間的異常型別和錯誤處理模式不同。

PDFmyURL錯誤處理:

try
{
    var pdf = new PDFmyURL("your-license-key");
    pdf.ConvertURL(url, file);
}
catch (Exception ex)
{
    Console.WriteLine("Error: " + ex.Message);
}
try
{
    var pdf = new PDFmyURL("your-license-key");
    pdf.ConvertURL(url, file);
}
catch (Exception ex)
{
    Console.WriteLine("Error: " + ex.Message);
}
Imports System

Try
    Dim pdf As New PDFmyURL("your-license-key")
    pdf.ConvertURL(url, file)
Catch ex As Exception
    Console.WriteLine("Error: " & ex.Message)
End Try
$vbLabelText   $csharpLabel

IronPDF錯誤處理:

try
{
    var pdf = renderer.RenderUrlAsPdf(url);
    pdf.SaveAs(file);
}
catch (IronPdf.Exceptions.IronPdfRenderingException e)
{
    Console.WriteLine("Error: " + e);
}
try
{
    var pdf = renderer.RenderUrlAsPdf(url);
    pdf.SaveAs(file);
}
catch (IronPdf.Exceptions.IronPdfRenderingException e)
{
    Console.WriteLine("Error: " + e);
}
Imports IronPdf.Exceptions

Try
    Dim pdf = renderer.RenderUrlAsPdf(url)
    pdf.SaveAs(file)
Catch e As IronPdfRenderingException
    Console.WriteLine("Error: " & e.ToString())
End Try
$vbLabelText   $csharpLabel

PDFmyURL為API相關問題(網路故障、認證問題)拋出標準.NET異常。 它還支持WebException事件處理程式來處理異步錯誤。 IronPDF使用標準.NET異常模式,具有特定的異常型別,如IronPdfRenderingException

當團隊考慮從PDFmyURL轉向IronPDF

有幾個因素促使團隊評估IronPDF作為PDFmyURL的替代品:

隱私和合規要求: 需要處理敏感資料的組織通常不能將文件發送到外部伺服器。 IronPDF的本地處理直接滿足了這一要求。

成本可預測性: PDFmyURL的訂閱模式會隨著項目壽命的增長而產生持續的費用。 IronPDF的永久授權選項提供了固定成本,無需擔心基於容量的擴展。

離線能力: 部署在受限網路環境下或需離線功能的應用程式不能依賴於雲端API。IronPDF在初始設置後不需要網際網路連接即可工作。

擴展的PDF功能: PDFmyURL專注於轉換,而IronPDF提供了額外的功能——合併、拆分、提取文字、水印、表單填寫和數位簽名——均在單個程式庫內。

速率限制消除: 高容量應用程式可能會在高峰使用期間遇到PDFmyURL的限制。 IronPDF在沒有外部約束的情況下處理無限文件。

服務依賴移除: 雲端API的可用性影響應用程式的可靠性。 本地處理消除了對第三方服務正常運行時間的依賴。

安裝比較

PDFmyURL安裝:pdfmyurl.com下載32位或64位的PDFmyURL.NET.dll,並將參考新增到您的專案中。 需要授權金鑰。

IronPDF安裝:

IronPDF需要授權金鑰配置:

IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

IronPDF通過NuGet安裝,支持.NET Framework、.NET Core、.NET 5+,以及未來相容.NET 10和C# 14。

做出決策

在PDFmyURL和IronPDF之間的選擇反映了不同的應用程式需求和組織優先事項:

考慮PDFmyURL如果: 您需要快速整合低容量應用程式,對文件處理沒有隱私限制,偏好操作簡單勝過基礎設施控制,並接受持續的訂閱成本。

考慮IronPDF如果: 您需要處理需要本地處理的敏感文件,無需訂閱費用即可預測成本,需離線能力或在受限網路中運行,想要轉換之外的擴展PDF功能,或高容量無速率限制問題。

對於大多數生產應用程式——特別是那些處理業務文件、客戶資料或在合規要求下運行的應用程式——IronPDF的本地處理架構在隱私、成本可預測性和功能廣度上提供了顯著優勢。

開始使用 IronPDF

要評估您的 PDF 生成需求的 IronPDF:

  1. 通過NuGet安裝:Install-Package IronPdf
  2. 查看入門文件
  3. 探索HTML到PDF教程以了解轉換模式
  4. 檢查API參考以獲得完整的方法文件

IronPDF教程提供了涵蓋從基本轉換到高級PDF操作的常見場景的完整範例。

結論

PDFmyURL和IronPDF在.NET應用程式中的PDF生成提供了根本不同的方法。 PDFmyURL提供了雲端的便利性,但其代價是外部資料處理、持續的訂閱費用和網際網路依賴性。 IronPDF提供本地處理控制,具有隱私保證、永久授權選項和擴展PDF功能。

決策超越了技術實施,涉及到處理資料的組織要求、成本結構和功能需求。 對於需要文件隱私、可預測經濟效益或超過基本轉換功能的應用程式,IronPDF的本地處理架構提供了在您控制環境中的全面解決方案。

選擇這些方法時,評估您的具體需求——隱私限制、容量預期、功能需求和成本偏好。 處理位置的選擇不僅影響技術實施,還影響合規姿態、運營成本和長期應用程式架構。

請注意PDFCrowd和PDFMyUrl是其各自所有者的註冊商標。 本網站未與PDFmyURL或PDFcrowd聯屬、贊助或獲其批准。 所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時公開的資訊。)}