Przejdź do treści stopki
PRZEWODNIKI MIGRACJI

Jak przeprowadzić migrację z PDFmyURL do IronPDF w języku C#

PDFmyURL is a cloud-based API service designed for converting URLs and HTML content to PDF documents. The service processes all conversions on external servers, providing a straightforward integration path that requires minimal local infrastructure. However, this cloud-dependent architecture creates significant concerns for production applications that handle sensitive data, require offline capability, or need to avoid ongoing subscription costs.

This guide provides a complete migration path fromPDFmyURLto IronPDF, with step-by-step instructions, code comparisons, and practical examples for professional .NET developers evaluating this transition.

Why Migrate from PDFmyURL

PDFmyURL's cloud processing model introduces several challenges that development teams must consider:

Privacy & Data Security: Every document you convert travels to and through PDFmyURL's servers—sensitive contracts, financial reports, and personal data are all processed externally.

Ongoing Subscription Costs: Starting at $39/month, annual costs exceed $468/year with no ownership. This subscription model means continuous expenditure regardless of usage patterns.

Internet Dependency: Every conversion requires network connectivity. Applications cannot process PDFs offline or during network outages.

Rate Limits & Throttling: API calls can be throttled during peak usage, potentially impacting application performance.

Service Availability: Your application depends on a third-party service being online and functional.

Vendor Lock-in: API changes can break your integration without notice, requiring reactive code updates.

IronPDFvs PDFmyURL: Feature Comparison

Zrozumienie różnic architektonicznych pomaga decydentom technicznym w ocenie inwestycji w migrację:

Aspekt PDFmyURL IronPDF
Miejsce przetwarzania Serwery zewnętrzne Lokalnie (na Twoim serwerze)
Typ API Wrapper Biblioteka .NET
Uwierzytelnianie Klucz API na żądanie Jednorazowy klucz licencyjny
Wymagana sieć Every conversion Tylko wstępna konfiguracja
Model cenowy Monthly subscription ($39+) Dostępna jest Licencja wieczysta
Limity częstotliwości Tak (w zależności od planu) None
Ochrona danych Dane wysyłane na zewnątrz Dane pozostają lokalne
HTML/CSS/JS Support W3C compliant Pełny silnik Chromium
Wzorzec asynchroniczny Required (async only) Sync and async options
Manipulacja plikami PDF Ograniczone Full suite (merge, split, edit)
Przykład zastosowania Aplikacje o niewielkim natężeniu ruchu Duże ilości i Enterprise

Quick Start:PDFmyURLtoIronPDFMigration

Migrację można rozpocząć natychmiast, wykonując te podstawowe kroki.

Krok 1: Zastąp pakiety NuGet

RemovePDFmyURLpackages:

# RemovePDFmyURLpackages
dotnet remove package PdfMyUrl
dotnet remove package Pdfcrowd
# RemovePDFmyURLpackages
dotnet remove package PdfMyUrl
dotnet remove package Pdfcrowd
SHELL

Zainstaluj IronPDF:

# Install IronPDF
dotnet add package IronPdf
# Install IronPDF
dotnet add package IronPdf
SHELL

Krok 2: Aktualizacja przestrzeni nazw

ReplacePDFmyURLnamespaces with IronPdf:

// Before: PDFmyURL
using PdfMyUrl;
using Pdfcrowd;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
// Before: PDFmyURL
using PdfMyUrl;
using Pdfcrowd;

// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
' Before: PDFmyURL
Imports PdfMyUrl
Imports Pdfcrowd

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

Krok 3: Inicjalizacja licencji

Dodaj inicjalizację licencji podczas uruchamiania aplikacji:

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

Przykłady migracji kodu

Konwersja adresów URL do formatu PDF

The URL-to-PDF operation demonstrates the fundamental API differences betweenPDFmyURLand IronPDF.

PDFmyURL Approach:

// InstallPDFmyURLSDK
using System;
using Pdfcrowd;

class Example
{
    static void Main()
    {
        try
        {
            var client = new HtmlToPdfClient("username", "apikey");
            client.convertUrlToFile("https://example.com", "output.pdf");
        }
        catch(Error why)
        {
            Console.WriteLine("Error: " + why);
        }
    }
}
// InstallPDFmyURLSDK
using System;
using Pdfcrowd;

class Example
{
    static void Main()
    {
        try
        {
            var client = new HtmlToPdfClient("username", "apikey");
            client.convertUrlToFile("https://example.com", "output.pdf");
        }
        catch(Error why)
        {
            Console.WriteLine("Error: " + why);
        }
    }
}
Imports System
Imports Pdfcrowd

Class Example
    Shared Sub Main()
        Try
            Dim client = New HtmlToPdfClient("username", "apikey")
            client.convertUrlToFile("https://example.com", "output.pdf")
        Catch why As Error
            Console.WriteLine("Error: " & why)
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

Podejście IronPDF:

// 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 requires creating an HtmlToPdfClient with username and API key credentials for every conversion request, then calling convertUrlToFile() with both the URL and output path. The entire operation must be wrapped in try-catch for PDFmyURL's custom Error type.

IronPDF simplifies this to three lines: create a ChromePdfRenderer, call RenderUrlAsPdf(), and use the built-in SaveAs() method. No per-request credentials are needed—the license is set once at application startup.

For advanced URL-to-PDF scenarios, see the URL to PDF documentation.

Converting HTML Strings to PDF

HTML string conversion shows the pattern differences clearly.

PDFmyURL Approach:

// InstallPDFmyURLSDK
using System;
using Pdfcrowd;

class Example
{
    static void Main()
    {
        try
        {
            var client = new HtmlToPdfClient("username", "apikey");
            string html = "<html><body><h1>Hello World</h1></body></html>";
            client.convertStringToFile(html, "output.pdf");
        }
        catch(Error why)
        {
            Console.WriteLine("Error: " + why);
        }
    }
}
// InstallPDFmyURLSDK
using System;
using Pdfcrowd;

class Example
{
    static void Main()
    {
        try
        {
            var client = new HtmlToPdfClient("username", "apikey");
            string html = "<html><body><h1>Hello World</h1></body></html>";
            client.convertStringToFile(html, "output.pdf");
        }
        catch(Error why)
        {
            Console.WriteLine("Error: " + why);
        }
    }
}
Imports System
Imports Pdfcrowd

Class Example
    Shared Sub Main()
        Try
            Dim client = New HtmlToPdfClient("username", "apikey")
            Dim html As String = "<html><body><h1>Hello World</h1></body></html>"
            client.convertStringToFile(html, "output.pdf")
        Catch why As Error
            Console.WriteLine("Error: " & why.ToString())
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

Podejście IronPDF:

// 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 uses convertStringToFile() which sends the HTML content to external servers for processing. IronPDF's RenderHtmlAsPdf() processes everything locally using the Chromium rendering engine.

Explore the HTML to PDF conversion guide for additional options.

HTML File Conversion with Page Settings

Configuring paper size, orientation, and margins requires different approaches in each library.

PDFmyURL Approach:

// InstallPDFmyURLSDK
using System;
using Pdfcrowd;

class Example
{
    static void Main()
    {
        try
        {
            var client = new HtmlToPdfClient("username", "apikey");
            client.setPageSize("A4");
            client.setOrientation("landscape");
            client.setMarginTop("10mm");
            client.convertFileToFile("input.html", "output.pdf");
        }
        catch(Error why)
        {
            Console.WriteLine("Error: " + why);
        }
    }
}
// InstallPDFmyURLSDK
using System;
using Pdfcrowd;

class Example
{
    static void Main()
    {
        try
        {
            var client = new HtmlToPdfClient("username", "apikey");
            client.setPageSize("A4");
            client.setOrientation("landscape");
            client.setMarginTop("10mm");
            client.convertFileToFile("input.html", "output.pdf");
        }
        catch(Error why)
        {
            Console.WriteLine("Error: " + why);
        }
    }
}
Imports System
Imports Pdfcrowd

Class Example
    Shared Sub Main()
        Try
            Dim client = New HtmlToPdfClient("username", "apikey")
            client.setPageSize("A4")
            client.setOrientation("landscape")
            client.setMarginTop("10mm")
            client.convertFileToFile("input.html", "output.pdf")
        Catch why As Error
            Console.WriteLine("Error: " & why.ToString())
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

Podejście 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 uses setter methods with string parameters like setPageSize("A4") and setMarginTop("10mm").IronPDFprovides strongly-typed properties through RenderingOptions with enums like PdfPaperSize.A4 and integer values for margins in millimeters.

PDFmyURLAPI toIronPDFMapping Reference

To mapowanie przyspiesza migrację, pokazując bezpośrednie odpowiedniki API:

Klasy podstawowe

PDFmyURL IronPDF
HtmlToPdfClient ChromePdfRenderer
PdfMyUrlClient ChromePdfRenderer
API response object PdfDocument

Methods

PDFmyURL IronPDF
client.convertUrlToFile(url, file) renderer.RenderUrlAsPdf(url).SaveAs(file)
client.convertStringToFile(html, file) renderer.RenderHtmlAsPdf(html).SaveAs(file)
client.convertFileToFile(input, output) renderer.RenderHtmlFileAsPdf(input).SaveAs(output)
response.GetBytes() pdf.BinaryData
response.GetStream() pdf.Stream

Opcje konfiguracji

PDFmyURL(setXxx methods) IronPDF(RenderingOptions)
setPageSize("A4") .PaperSize = PdfPaperSize.A4
setPageSize("Letter") .PaperSize = PdfPaperSize.Letter
setOrientation("landscape") .PaperOrientation = PdfPaperOrientation.Landscape
setOrientation("portrait") .PaperOrientation = PdfPaperOrientation.Portrait
setMarginTop("10mm") .MarginTop = 10
setMarginBottom("10mm") .MarginBottom = 10
setMarginLeft("10mm") .MarginLeft = 10
setMarginRight("10mm") .MarginRight = 10
setHeaderHtml(html) .HtmlHeader = new HtmlHeaderFooter { HtmlFragment = html }
setFooterHtml(html) .HtmlFooter = new HtmlHeaderFooter { HtmlFragment = html }
setJavaScriptDelay(500) .RenderDelay = 500
setDisableJavaScript(true) .EnableJavaScript = false
setUsePrintMedia(true) .CssMediaType = PdfCssMediaType.Print

Authentication Comparison

PDFmyURL IronPDF
new HtmlToPdfClient("username", "apikey") IronPdf.License.LicenseKey = "LICENSE-KEY"
Klucz API na żądanie One-time at startup
Wymagane dla każdego wywołania Set once globally

Typowe problemy związane z migracją i ich rozwiązania

Issue 1: API Key vs License Key

PDFmyURL: Requires credentials for every conversion request.

Solution: Set theIronPDFlicense once at application startup:

// PDFmyURL: API key per request
var client = new HtmlToPdfClient("username", "apikey");

// IronPDF: One-time license at startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Set once, typically in Program.cs or Startup.cs
// PDFmyURL: API key per request
var client = new HtmlToPdfClient("username", "apikey");

// IronPDF: One-time license at startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Set once, typically in Program.cs or Startup.cs
Imports IronPdf

' PDFmyURL: API key per request
Dim client As New HtmlToPdfClient("username", "apikey")

' IronPDF: One-time license at startup
License.LicenseKey = "YOUR-LICENSE-KEY"
' Set once, typically in Program.vb or Startup.vb
$vbLabelText   $csharpLabel

Issue 2: Placeholder Syntax in Headers/Footers

PDFmyURL: Uses {page_number} and {total_pages} placeholders.

Solution: Update to IronPDF's placeholder format:

// PDFmyURL: "Page {page_number} of {total_pages}"
// IronPDF: "Page {page} of {total-pages}"
// PDFmyURL: "Page {page_number} of {total_pages}"
// IronPDF: "Page {page} of {total-pages}"
' PDFmyURL: "Page {page_number} of {total_pages}"
' IronPDF: "Page {page} of {total-pages}"
$vbLabelText   $csharpLabel

Issue 3: Async Patterns

PDFmyURL: Requires async/await patterns.

Solution:IronPDFis synchronous by default; wrap for async if needed:

// PDFmyURL: Native async
var response = await client.ConvertUrlAsync(url);

// IronPDF: Sync by default, wrap for async
var pdf = await Task.Run(() => renderer.RenderUrlAsPdf(url));
// PDFmyURL: Native async
var response = await client.ConvertUrlAsync(url);

// IronPDF: Sync by default, wrap for async
var pdf = await Task.Run(() => renderer.RenderUrlAsPdf(url));
Imports System.Threading.Tasks

' PDFmyURL: Native async
Dim response = Await client.ConvertUrlAsync(url)

' IronPDF: Sync by default, wrap for async
Dim pdf = Await Task.Run(Function() renderer.RenderUrlAsPdf(url))
$vbLabelText   $csharpLabel

Issue 4: Error Handling

PDFmyURL: Uses custom Pdfcrowd.Error exception type.

Solution: Update catch blocks forIronPDFexceptions:

// PDFmyURL: Pdfcrowd.Error
catch (Pdfcrowd.Error e) { ... }

// IronPDF: Standard exceptions
catch (IronPdf.Exceptions.IronPdfRenderingException e) { ... }
// PDFmyURL: Pdfcrowd.Error
catch (Pdfcrowd.Error e) { ... }

// IronPDF: Standard exceptions
catch (IronPdf.Exceptions.IronPdfRenderingException e) { ... }
$vbLabelText   $csharpLabel

Issue 5: Configuration Pattern

PDFmyURL: Uses setter methods with string values.

Solution: Use strongly-typed RenderingOptions properties:

// PDFmyURL: Setter methods
client.setPageSize("A4");
client.setOrientation("landscape");

// IronPDF: Properties with enums
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
// PDFmyURL: Setter methods
client.setPageSize("A4");
client.setOrientation("landscape");

// IronPDF: Properties with enums
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
' PDFmyURL: Setter methods
client.setPageSize("A4")
client.setOrientation("landscape")

' IronPDF: Properties with enums
renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape
$vbLabelText   $csharpLabel

PDFmyURLMigration Checklist

Zadania przed migracją

Audit your codebase to identify allPDFmyURLusage:

# FindPDFmyURLusage
grep -r "PdfMyUrl\|Pdfcrowd\|HtmlToPdfClient" --include="*.cs" .

# Find API key references
grep -r "apikey\|api-key\|api_key" --include="*.cs" --include="*.json" --include="*.config" .

# Find placeholder patterns to migrate
grep -r "{page_number}\|{total_pages}" --include="*.cs" .
# FindPDFmyURLusage
grep -r "PdfMyUrl\|Pdfcrowd\|HtmlToPdfClient" --include="*.cs" .

# Find API key references
grep -r "apikey\|api-key\|api_key" --include="*.cs" --include="*.json" --include="*.config" .

# Find placeholder patterns to migrate
grep -r "{page_number}\|{total_pages}" --include="*.cs" .
SHELL

Document current configuration options used. Plan license key storage using environment variables.

Zadania związane z aktualizacją kodu

  1. Remove PDFmyURL/Pdfcrowd NuGet packages
  2. Zainstaluj pakiet IronPdf NuGet
  3. Update all namespace imports
  4. Replace API key authentication withIronPDFlicense key
  5. Convert setter methods to RenderingOptions properties
  6. Update placeholder syntax in headers/footers ({page_number}{page}, {total_pages}{total-pages})
  7. Update error handling code forIronPDFexception types
  8. AddIronPDFlicense initialization at startup

Testy po migracji

Po migracji należy zweryfikować następujące aspekty:

  • Test PDF output quality matches expectations
  • Verify async patterns work correctly
  • Compare rendering fidelity with previous output
  • Sprawdź, czy wszystkie warianty szablonów wyświetlają się poprawnie
  • Validate page settings (size, orientation, margins)
  • Install Linux dependencies if deploying to Linux servers

Kluczowe korzyści z migracji do IronPDF

Moving fromPDFmyURLtoIronPDFprovides several critical advantages:

Complete Privacy: Documents never leave your server. All processing happens locally, eliminating data security concerns for sensitive content.

One-Time Cost: Perpetual license option eliminates recurring subscription fees. No more monthly payments regardless of usage volume.

Offline Capability: Works without internet after initial setup. Network outages don't impact PDF generation.

No Rate Limits: Process unlimited documents without throttling concerns.

Lower Latency: No network overhead means faster conversions, especially for high-volume applications.

Full Control: You control the processing environment, not a third-party service.

Modern Chromium Engine: Full CSS3 and JavaScript support with the same rendering engine that powers Chrome browser.

Aktywny rozwój: W miarę jak do 2026 r. wzrośnie popularność .NET 10 i C# 14, regularne aktualizacjeIronPDFzapewnią zgodność z obecnymi i przyszłymi wersjami .NET.

Curtis Chau
Autor tekstów technicznych

Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podrę...

Czytaj więcej

Zespol wsparcia Iron

Jestesmy online 24 godziny, 5 dni w tygodniu.
Czat
Email
Zadzwon do mnie