C#でPDFmyURLからIronPDFへ移行する方法
PDFmyURLは、URLとHTMLコンテンツをPDFドキュメントに変換するために設計されたクラウドベースのAPIサービスです。 このサービスでは、すべての変換を外部サーバーで処理するため、ローカルインフラを最小限に抑えた、わかりやすい統合パスを提供します。 しかし、このようなクラウド依存のアーキテクチャは、機密データを扱ったり、オフライン機能を必要としたり、継続的なサブスクリプションコストを回避する必要がある本番アプリケーションにとって、重大な懸念を生じさせます。
このガイドはPDFmyURLからIronPDFへの完全な移行経路を、移行を検討しているプロ for .NET開発者のために、ステップバイステップの説明、コード比較、実用的な例とともに提供します。
なぜPDFmyURLから移行するのですか?
PDFmyURLのクラウド処理モデルには、開発チームが考慮しなければならないいくつかの課題があります:
プライバシーとデータ セキュリティ:変換するすべてのドキュメントはPDFmyURLのサーバーに送信され、サーバーを通過します。機密性の高い契約書、財務レポート、個人データはすべて外部で処理されます。
継続的なサブスクリプション費用:月額39ドルから始まり、所有権なしで年間468ドルを超える費用がかかります。このサブスクリプションモデルは、使用パターンに関係なく継続的な費用がかかります。
インターネット依存性:すべての変換にはネットワーク接続が必要です。 アプリケーションは、オフラインまたはネットワーク停止中にPDFを処理することはできません。
レート制限とスロットリング:ピーク使用時には API 呼び出しがスロットリングされ、アプリケーションのパフォーマンスに影響を及ぼす可能性があります。
サービスの可用性:アプリケーションは、サードパーティのサービスがオンラインで機能していることに依存します。
ベンダー ロックイン: API の変更により、予告なしに統合が中断される可能性があり、事後的なコード更新が必要になります。
IronPDFとPDFmyURLの比較:機能の比較
アーキテクチャの違いを理解することは、技術的な意思決定者が移行への投資を評価するのに役立ちます:
| アスペクト | PDFmyURL | IronPDF |
|---|---|---|
| 加工場所 | 外部サーバー | ローカル(お客様のサーバー) |
| タイプ | APIラッパー | .NET ライブラリ |
| 認証。 | リクエストごとのAPIキー | ワンタイムライセンスキー |
| ネットワークが必要です。 | すべての変換 | 初期設定のみ |
| 価格設定モデル | 月額サブスクリプション(39ドル以上) | 永久ライセンスあり |
| 料金の制限 | あり(プランによる) | なし |
| データプライバシー | 外部送信データ | データはローカルのまま |
| HTML/CSS/JSサポート。 | W3C準拠 | フルChromiumエンジン |
| 非同期パターン | 必須(非同期のみ) | 同期と非同期のオプション |
| PDF操作 | 制限的 | フルスイート(マージ、分割、編集) |
| ユースケース | 少量のアプリケーション | 大容量およびエンタープライズ |
クイックスタートPDFmyURLからIronPdfへの移行
これらの基本的なステップを踏めば、すぐにでも移行を開始できます。
ステップ 1: NuGet パッケージを置き換える
PDFmyURLパッケージを削除してください:
# RemovePDFmyURLpackages
dotnet remove package PdfMyUrl
dotnet remove package Pdfcrowd
# RemovePDFmyURLpackages
dotnet remove package PdfMyUrl
dotnet remove package Pdfcrowd
IronPDFをインストールします:
# Install IronPDF
dotnet add package IronPdf
# Install IronPDF
dotnet add package IronPdf
ステップ 2: 名前空間の更新
PDFmyURLの名前空間を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
ステップ 3: ライセンスの初期化
アプリケーション起動時のライセンス初期化を追加します:
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
コード移行の例
URLをPDFに変換する
URLからPDFへの操作はPDFmyURLとIronPDFの基本的なAPIの違いを示します。
PDFmyURLのアプローチ:
// 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
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
PDFmyURL では、すべての変換リクエストに対してユーザー名と API キー資格情報を使用して HtmlToPdfClient を作成し、URL と出力パスの両方を使用して convertUrlToFile() を呼び出す必要があります。PDFmyURLのカスタム Error 型の場合、操作全体を try-catch でラップする必要があります。
IronPDF はこれを 3 行に簡略化します: ChromePdfRenderer を作成し、RenderUrlAsPdf() を呼び出し、組み込みの SaveAs() メソッドを使用します。 ライセンスは、アプリケーションの起動時に一度だけ設定されます。
高度なURL-to-PDFシナリオについては、URL to PDF documentationを参照してください。
HTML文字列をPDFに変換する
HTML文字列変換は、パターンの違いを明確に示します。
PDFmyURLのアプローチ:
// 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
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
PDFmyURL は、HTML コンテンツを処理のために外部サーバーに送信する convertStringToFile() を使用します。IronPDFの RenderHtmlAsPdf() は、Chromium レンダリング エンジンを使用してすべてをローカルで処理します。
その他のオプションについては、HTMLからPDFへの変換ガイドをご覧ください。
ページ設定による HTML ファイルの変換
用紙サイズ、向き、余白を設定するには、各ライブラリで異なるアプローチが必要です。
PDFmyURLのアプローチ:
// 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
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
PDFmyURL は、setPageSize("A4") や setMarginTop("10mm") のような文字列パラメータを持つ setter メソッドを使用します。IronPDFは、RenderingOptions を通じて、PdfPaperSize.A4 のような列挙型と、ミリメートル単位の余白の整数値を使用して、厳密に型指定されたプロパティを提供します。
PDFmyURLAPIからIronPDFへのマッピングリファレンス
このマッピングは、APIと同等のものを直接示すことで、移行を加速します:
コアクラス
| PDFmyURL | IronPDF |
|---|---|
HtmlToPdfClient |
ChromePdfRenderer |
PdfMyUrlClient |
ChromePdfRenderer |
| APIレスポンスオブジェクト | PdfDocument |
メソッド
| 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 |
設定オプション
| PDFmyURL (setXxxメソッド) | 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 |
認証の比較
| PDFmyURL | IronPDF |
|---|---|
new HtmlToPdfClient("username", "apikey") |
IronPdf.License.LicenseKey = "LICENSE-KEY" |
| リクエストごとのAPIキー | スタートアップで1回のみ |
| すべての通話に必要 | グローバルに1回設定 |
一般的な移行の問題と解決策
課題 1: API キーとライセンス キーの比較
PDFmyURL:変換リクエストごとに認証情報が必要です。
解決策:アプリケーションの起動時にIronPDFライセンスを一度だけ設定します:
// 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
課題2:ヘッダー/フッターのプレースホルダー構文
PDFmyURL: {page_number} および {total_pages} プレースホルダーを使用します。
解決策: IronPDFのプレースホルダー形式に更新する:
// 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}"
第3号:非同期パターン
PDFmyURL:非同期/待機パターンが必要です。
ソリューション: IronPDFはデフォルトで同期です; 必要であれば、asyncをラップしてください:
// 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))
課題 4: エラー処理
PDFmyURL:カスタム Pdfcrowd.Error 例外タイプを使用します。
解決策: IronPDF例外のキャッチブロックを更新する:
// 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) { ... }
第5号:構成パターン
PDFmyURL:文字列値を持つセッターメソッドを使用します。
解決策: 強く型付けされたRenderingOptionsプロパティを使用してください:
// 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
PDFmyURL移行チェックリスト
マイグレーション前のタスク
コードベースを監査して、すべてのPDFmyURLの使用法を特定してください:
# 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" .
現在使用されている設定オプションを文書化すること。 環境変数を使用してライセンスキーの保存を計画する。
コード更新タスク
1.PDFmyURL/Pdfcrowd NuGetパッケージの削除 2.IronPdf NuGetパッケージをインストールする 3.すべての名前空間インポートの更新 4.APIキー認証をIronPDFライセンスキーに置き換える 5.セッターメソッドをRenderingOptionsプロパティに変換する
- ヘッダー/フッターのプレースホルダー構文を更新します (
{page_number}→{total_pages}→{total-pages}) 7.IronPDF例外タイプのエラー処理コードの更新 8.起動時にIronPDFライセンスの初期化を追加する
移行後のテスト
移行後、これらの点を検証してください:
- PDF出力の品質が期待に沿うかテスト
- 非同期パターンが正しく動作することを確認する
- レンダリングの忠実度を以前の出力と比較する
- すべてのテンプレートバリエーションが正しくレンダリングされることをテストする
- ページ設定の検証(サイズ、向き、余白)
- Linuxサーバーにデプロイする場合は、Linuxの依存関係をインストールしてください。
IronPDFに移行する主な利点
PDFmyURLからIronPDFに移行することで、いくつかの重要な利点が得られます:
完全なプライバシー:ドキュメントはサーバーから外部に漏れることはありません。 すべての処理はローカルで行われるため、機密性の高いコンテンツに対するデータセキュリティの懸念はありません。
一度限りのコスト:永久ライセンス オプションにより、定期的なサブスクリプション料金が不要になります。 使用量に関係なく、毎月の支払いはもう必要ありません。
オフライン機能:初期設定後はインターネットに接続しなくても動作します。ネットワークが切断されてもPDF生成には影響しません。
レート制限なし:スロットルを気にすることなく、無制限のドキュメントを処理できます。
低レイテンシ:ネットワーク オーバーヘッドがないため、特に大容量アプリケーションの場合、変換が高速になります。
完全な制御:サードパーティのサービスではなく、処理環境を制御します。
最新の Chromium エンジン: Chrome ブラウザと同じレンダリング エンジンで、CSS3 とJavaScript を完全にサポートします。
積極的な開発: .NET 10 と C# 14 の採用が 2026 年まで増加するにつれて、IronPDF の定期的な更新により、現在のおよび将来 for .NETバージョンとの互換性が確保されます。

