製品比較

IronPDFとPDFCrowdの比較

更新済み 12月 13, 2021
共有:

IronPDFとPDFCrowd - 徹底比較

進化し続ける技術は、誰にとっても、特に開発者にとって、より賢く時間を節約するソリューションをもたらします。 自動化は現在、ソフトウェア開発プロセスの鍵となっています。 C#でPDFファイルを扱うことは、長年にわたり開発者にとって難しいものでした。 PDFファイルからコンテンツをレンダリングする際には多くの要素を考慮する必要があり、異なる形式のコンテンツをPDFに変換する場合にはさらに多くの要素を考慮する必要があります。 これらの問題は、さまざまな形式からPDFを読み込み、書き込み、作成、および変換するために設計された多数のライブラリの完成により、現在解決されています。

この記事では、.NETおよび.NET Core開発者向けの最も人気のあるPDFライブラリ2つを比較します。 これらの2つのライブラリは:

IronPDF

  • PDFCrowd

    IronPDFとPDFCrowdはどちらも、PDFの作成、操作、および PDFを印刷する .NETおよび.NET Coreで。 次の質問は、どちらを選ぶか決定することです C# PDFライブラリ あなたの.NETプロジェクトに最適なのはどれですか? 次のライブラリ間の比較と、それぞれのPDF変換および操作における際立った機能についての説明を読むことで、あなたの決断を評価することができます。

    まず、両方のライブラリが提供する内容を見てから、比較に移りましょう。

IronPDFとその主な機能

IronPDF .NET PDF Library ソリューションは、特にC#を使用するソフトウェアエンジニアにとって開発者の夢です。 この優れたツールを使用すると、簡単に.NET用のコアPDFライブラリを作成できます。

IronPDFは、.NETのChromiumエンジンを使用してHTMLページをPDFファイルに変換します。 HTMLからPDFへの変換では、PDFの配置やデザインに複雑なAPIを使用する必要はありません。 IronPDFは、標準的なウェブ文書であるHTML、ASPX、JS、CSS、画像に対応しています。

また、HTML5、CSS、JavaScript、および画像を使用して .NET PDF ライブラリを作成することもできます。 PDFに簡単に編集、スタンプ、ヘッダーおよびフッターを追加できます。 さらに、それを非常に簡単にします。 PDFを読む テキストと画像を抽出。

IronPDF C#ライブラリ - 際立った特徴

重要な機能には次のものが含まれます:

PDFを作成 (HTML から PDF)

  • HTML 4および5、CSS、JavaScriptからPDFドキュメントを作成する
  • URLからPDF文書を生成

  • カスタムネットワークログイン資格情報、ユーザーエージェント、プロキシ、クッキー、HTTPヘッダー、フォーム変数を使用して、HTMLログインフォームの背後でログインできるURLをロードする

    Adobe Acrobatを使わずに既存のPDFドキュメントを編集

  • フォームフィールドデータを読み取り、入力します
  • PDFから画像とテキストを抽出
  • 既存のPDFページに新しいHTMLコンテンツをスタンプします
  • ロジカルヘッダーまたはHTMLヘッダーおよびフッターを追加

    既存のPDFドキュメントを操作する

  • 既存のPDFドキュメントを読み込み、解析する
  • PDFドキュメントのコンテンツを結合および分割

  • ヘッダー、フッター、注釈、ブックマーク、透かし、テキスト、および画像アセットを追加します。

    複数のフォーマットから変換

  • ASPX WebForms – 3行のコードで、ASP.NET WebFormsをブラウザーで表示可能なダウンロード可能なPDFに変換します
  • HTMLドキュメント – HTMLをPDFに変換
  • カスタム「ベースURL」を設定して、ウェブ全体でアクセス可能なアセットファイルを利用可能にします。
  • 仮想ビューポートによるレスポンシブレイアウト (幅と高さ)

  • 任意の主要なファイルエンコーディングでエンコードされたHTMLを受け入れる (デフォルトでUTF-8)

    保存と印刷

  • ファイル、バイナリデータ、またはMemoryStreamsから保存および読み込み
  • スクリーンまたはプリントCSSメディアタイプ
  • PDFファイルをPrintDocumentオブジェクトに変換して、Adobeを使用せずに印刷します。 (最小限のコードで)
  • 公式ログファイルをエクスポートし、API成功およびソースコード内のデバッグエラーの詳細を表示します。

PDFCrowdライブラリ - 特徴的な機能

Pdfcrowd.com APIは、ウェブページおよびHTMLドキュメントからPDFおよびスクリーンショット画像を作成するためのプロフェッショナルソリューションです。 任意のウェブページをPDFに変換できるオンラインウェブサービスです。 APIは、入力がPDFCrowdサーバーで変換されるウェブサービスです。

高品質で高速なため、時間を節約できます。安全でファイルを圧縮する機能を持ちます。

PDFCrowd APIの機能

以下は、PDFCrowdの最も重要な機能の一部です:

HTMLからPDFへのAPI

  • 使いやすいAPIクライアントSDKライブラリ
  • 最新のWeb標準のサポート
  • 統合のセットアップには数分しかかかりません。サードパーティのライブラリは必要ありません。
  • ほぼすべてのプラットフォームで利用可能 - Windows、Linux、macOS、BSD、Unix系システムなど。

  • 信頼性が高く、広く利用可能で、最新のHTML5、CSS3、およびJavaScript仕様をサポートしています。

    APIプレイグラウンド

  • API設定をインタラクティブに探索する
  • PDFプレビュー、自動コード生成

  • ウェブページ、HTMLファイルまたはHTMLコードを変換

    注意: PDFCrowd は、オフラインで使用できるスタンドアロンSDKを提供していません。

    この記事の残りの部分では、以下のトピックについて説明します。

  1. プロジェクトを作成

  2. IronPDF C# ライブラリのインストール

  3. PDFCrowd APIインストール

  4. 既存のURLからPDFを作成

  5. HTML入力文字列からPDFを作成

  6. ASPXページをPDFに変換

  7. XMLをPDFに変換

  8. 画像をPDFに変換

  9. ライセンス

  10. 概要と結論

ASP.NET プロジェクトの作成

ASP.NETウェブサイトを作成するには、次の手順に従います:

  • Visual Studio 2019を開く
  • メニューから「ファイル」をクリックし、「新しいプロジェクト」をクリックして新しいプロジェクトを作成してください。
  • プロジェクトタイプリストボックスでVisual C#の下にあるWebを選択します。
  • ASP.NET Web アプリケーションを選択 (.NETフレームワーク) 以下のスクリーンショットのように[OK]をクリックします。

    図1 申し訳ありませんが、翻訳するための具体的なコンテンツが提供されていないようです。翻訳したいテキストを提供してください。 新規プロジェクトダイアログボックス

  • 次の画面で、下のスクリーンショットに示されているように「Web Forms」を選択してください。

    図2 申し訳ありませんが、翻訳するための具体的なコンテンツが提供されていないようです。翻訳したいテキストを提供してください。 Web Forms (ウェブフォーム)

  • すべて選択しましたら、「OK」をクリックしてください。

    プロジェクトが作成され、ライブラリのテストを実行する準備がほぼ整いました。 しかし、私たちはまだそれらをインストールし、プロジェクトに統合する必要があります。 まずはIronPDFをインストールしましょう。

2. IronPDF C#ライブラリーのインストール

IronPDFライブラリをダウンロードしてインストールする方法は4つあります。 それらは次の通りです:

  1. Visual Studio を使用して

  2. 開発者コマンドプロンプト

  3. NuGetパッケージを直接ダウンロード

  4. IronPDF .DLLライブラリをダウンロード

    それぞれを詳しく見ていきましょう。

2.1 Visual Studioの使用

Visual Studio は、プロジェクトに NuGet パッケージをインストールするための NuGet パッケージ マネージャーを提供します。 それはプロジェクトメニューからアクセスするか、ソリューションエクスプローラーでプロジェクトを右クリックしてアクセスできます。 これらのオプションはどちらも、図3および図4のスクリーンショットに示されています。

図3 申し訳ありませんが、翻訳するための具体的なコンテンツが提供されていないようです。翻訳したいテキストを提供してください。 プロジェクトメニュー > NuGetパッケージの管理

図4 申し訳ありませんが、翻訳するための具体的なコンテンツが提供されていないようです。翻訳したいテキストを提供してください。 ソリューションエクスプローラーを右クリック

選択したら、以下のスクリーンショットに示されているように、IronPDFパッケージを探してインストールします。

図 5 申し訳ありませんが、翻訳するための具体的なコンテンツが提供されていないようです。翻訳したいテキストを提供してください。 NuGetパッケージからIronPDFをインストールする

2.2 開発者コマンドプロンプトの使用

IronPDF C#ライブラリをダウンロードしてインストールするもう一つの方法は、以下の手順を利用してIronPDF NuGetパッケージをDeveloper Command Prompt経由でインストールすることです。

  • Developer Command Prompt を開きます – 通常は Visual Studio フォルダー内にあります
  • 以下のコマンドを入力してください:
  :ProductInstall
  • Enterキーを押してください
  • これはパッケージをダウンロードしてインストールします。

  • Visual Studioプロジェクトをリロードして、使用を開始します。

2.3. NuGetパッケージを直接ダウンロードする

IronPDFをダウンロードしてインストールする3番目の方法は、以下の手順に従うことです。 これは、NuGetサイトに直接アクセスし、パッケージをダウンロードすることでできます。 以下の手順は:

  • ナビゲートして https://www.nuget.org/packages/IronPdf/
  • ダウンロードパッケージを選択
  • ダウンロードしたパッケージをダブルクリックしてください
  • パッケージがインストールされます。

  • Visual Studioプロジェクトをリロードして、使用を開始します。

ライブラリをダウンロードしてIronPDFをインストールする

ウェブサイトからIronPDF .DLLファイルを直接ダウンロードできます。それは直接ダウンロード可能です。 IronPDF DLL ダウンロード.

図6 申し訳ありませんが、翻訳するための具体的なコンテンツが提供されていないようです。翻訳したいテキストを提供してください。 IronPDF C#ライブラリを直接ダウンロード

次の手順を使用して、プロジェクト内でライブラリを参照してください:

  • ソリューションエクスプローラーでソリューションを右クリックします
  • 参照を選択
  • IronPDF.dllライブラリを参照
  • 「OK」をクリック

    すべて完了しました! IronPDFをダウンロードして、インストールし、使用する準備ができました。 しかし、その前にPDFCrowd APIをインストールする必要があります。

PDFCrowd APIのインストール

認証

Pdfcrowd APIクライアントを使用するには認証が必要です。 APIにアクセスするために使用する認証情報は、あなたのPdfcrowdのユーザー名とAPIキーです。

Pdfcrowd APIクライアントライブラリ for .NET

Pdfcrowd APIクライアントライブラリを使用すると、HTML、PDF、およびさまざまな画像フォーマット間の変換を実行できます。 .NET APIクライアントライブラリは、簡単な実装を可能にします Pdfcrowd API

Pdfcrowd API in your .NET applications.

PDFCrowd APIクライアントライブラリを.NETにインストールする方法は3つあります:

  1. Pdfcrowdクライアントのダイレクトダウンロード(Zip形式)

  2. Pdfcrowd公式クライアントパッケージのためのNuGetパッケージマネージャーを通して

  3. Pdfcrowd GitHubリポジトリ

    それぞれを詳しく見てみましょう。

3.1 直接ダウンロード

ダウンロード pdfcrowd-5.2.0-dotnet.zip、解凍してプロジェクトに pdfcrowd.dll への参照を追加します。

次の手順を使用して、プロジェクト内でライブラリを参照してください:

  • ソリューションエクスプローラーでソリューションを右クリックします
  • 参照を選択
  • pdfcrowd.dll ライブラリを参照する
  • 「OK」をクリック

3.2 開発者コマンドプロンプトを介してNuGetパッケージマネージャー

PDFCrowd APIをダウンロードおよびインストールするもう一つの方法は、以下の手順を使用して開発者コマンドプロンプトからPDFCrowd API Client NuGetパッケージをインストールすることです。

  • Developer Command Prompt を開いてください – 通常は Visual Studio フォルダーの下にあります。
  • 次のコマンドを入力してください:PM > Install-Package Pdfcrowd.official -Version 5.2.0
  • Enterキーを押してください
  • これはパッケージをダウンロードしてインストールします。

  • Visual Studioプロジェクトをリロードして、使用を開始します。

3.3 GitHubリポジトリ

PDFCrowd をインストールするには、クローンします pdfcrowd-dotnet GitHubからライブラリをビルドします。 このクライアントライブラリはMITライセンスの下でライセンスされています。

以下のコマンドを使用して、PDFCrowd API クライアントライブラリをビルドします:

  • git clone https://github.com/pdfcrowd/pdfcrowd-dotnet
  • cd pdfcrowd-dotnet
  • Windowsでの make.bat #
  • "Unixでmake all #を実行する"

    プロジェクトを作成し、必要なライブラリをインストールしたので、コードの観点からIronPDFとPDFCrowdライブラリを比較し始めましょう。

4. 既存のURLからPDFを作成する

どちらのライブラリもHTMLウェブページをPDFに変換する機能を提供します。 それぞれのライブラリのコードを一つずつ見ていきましょう。

4.1. IronPDF を使用して既存のURLをPDFに変換する

IronPDFは、既存のURLからHTMLをPDFドキュメントとしてレンダリングすることを非常に簡単にします。 JavaScript、画像、フォーム、CSSに対するサポートは非常に高いレベルにあります。

次のコードは、IronPDFを使用してウェブサイトのアドレスから直接PDFドキュメントを作成しています。

IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");

Pdf.SaveAs("url.pdf");
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");

Pdf.SaveAs("url.pdf");
Dim Renderer As New IronPdf.ChromePdfRenderer()
Dim Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")

Pdf.SaveAs("url.pdf")
VB   C#

4.2 PDFCrowdを使用して既存のURLをPDFに変換する

PDFCrowdを使用すると、URLをPDFドキュメントに変換するのも非常に簡単です。 以下のコードは、PDFCrowdを使用してウェブサイトのアドレスから直接PDFドキュメントを生成しています。

// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertUrlToFile("http://www.pdfcrowd.com", "example.pdf");
// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertUrlToFile("http://www.pdfcrowd.com", "example.pdf");
' create the API client instance
Dim client As New pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d")

' run the conversion and write the result to a file
client.convertUrlToFile("http://www.pdfcrowd.com", "example.pdf")
VB   C#

HTML入力文字列からPDFを作成

IronPDFとPDFCrowdの両方は、HTMLを含む文字列からPDFを生成する機能を提供します。 どちらも、このタスクを達成するためにわずか2行のコードを使用します。

5.1. IronPDFを使用したHTML入力文字列

以下のコードは、HTML入力文字列を使用してPDFドキュメントをレンダリングできることを示しています。 シンプルなHTMLを選択するか、CSS、画像、JavaScriptを取り入れることもできます。

var Renderer = new IronPdf.ChromePdfRenderer();
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
PDF.SaveAs("pixel-perfect.pdf");

// Load external html assets: images, css and javascript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from 
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
var Renderer = new IronPdf.ChromePdfRenderer();
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
PDF.SaveAs("pixel-perfect.pdf");

// Load external html assets: images, css and javascript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from 
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
Dim Renderer = New IronPdf.ChromePdfRenderer()
Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
PDF.SaveAs("pixel-perfect.pdf")

' Load external html assets: images, css and javascript.
' An optional BasePath 'C:\site\assets\' is set as the file location to load assets from 
Dim AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
AdvancedPDF.SaveAs("html-with-assets.pdf")
VB   C#

5.2. PDFCrowdを使用したHTML入力文字列

以下のコードは、HTMLを含む文字列を使用してPDFドキュメントを生成できることを示しています。 HTML入力文字列は、メモリ上のPDFに変換し、結果のPDFを出力ストリームに書き込むためにも使用できます。

// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertStringToFile("<html><body><h1>Hello World!</h1></body></html>", "HelloWorld.pdf");

// run the conversion and store the result into the "pdf" variable
byte [] pdf = client.convertString("<html><body><h1>Hello World!</h1></body></html>");
// at this point the "pdf" variable contains PDF raw data and
// can be sent in an HTTP response, saved to a file, etc.

// create an output stream for the conversion result
FileStream outputStream = new FileStream("HelloWorld.pdf", FileMode.CreateNew);

// run the conversion and write the result into the output stream
client.convertStringToStream("<html><body><h1>Hello World!</h1></body></html>", outputStream);

// close the output stream
outputStream.Close();
// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertStringToFile("<html><body><h1>Hello World!</h1></body></html>", "HelloWorld.pdf");

// run the conversion and store the result into the "pdf" variable
byte [] pdf = client.convertString("<html><body><h1>Hello World!</h1></body></html>");
// at this point the "pdf" variable contains PDF raw data and
// can be sent in an HTTP response, saved to a file, etc.

// create an output stream for the conversion result
FileStream outputStream = new FileStream("HelloWorld.pdf", FileMode.CreateNew);

// run the conversion and write the result into the output stream
client.convertStringToStream("<html><body><h1>Hello World!</h1></body></html>", outputStream);

// close the output stream
outputStream.Close();
' create the API client instance
Dim client As New pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d")

' run the conversion and write the result to a file
client.convertStringToFile("<html><body><h1>Hello World!</h1></body></html>", "HelloWorld.pdf")

' run the conversion and store the result into the "pdf" variable
Dim pdf() As Byte = client.convertString("<html><body><h1>Hello World!</h1></body></html>")
' at this point the "pdf" variable contains PDF raw data and
' can be sent in an HTTP response, saved to a file, etc.

' create an output stream for the conversion result
Dim outputStream As New FileStream("HelloWorld.pdf", FileMode.CreateNew)

' run the conversion and write the result into the output stream
client.convertStringToStream("<html><body><h1>Hello World!</h1></body></html>", outputStream)

' close the output stream
outputStream.Close()
VB   C#

ASPXページをPDFに変換

次のコードは、IronPDFとPDFCrowdの両方でASP.NETウェブページからPDFドキュメントを作成します。

ASPXページからPDFへの変換(IronPDFを使用)

以下のコードは、IronPDFを使用してASPXウェブページファイルをPDFにレンダリングします。 これは一行のコードで、とても使いやすいです。 レンダリング中にPDF設定にさらにオプションを追加できます。

protected void Page_Load(object sender, EventArgs e)
{
    IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
protected void Page_Load(object sender, EventArgs e)
{
    IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
	IronPdf.AspxToPdf.RenderThisPageAsPdf()
End Sub
VB   C#

6.2. PDFCrowdを使用してASPXページをPDFに変換

以下のコードは、PDFCrowdを使用してASPXウェブページファイルをPDFにレンダリングします。 これにより、完全なHTTPレスポンスヘッダーを設定し、HTTPレスポンスに結果を送信して、ウェブブラウザでPDFとして表示することができます。

// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and store the result into the "pdf" variable
byte [] pdf = client.convertUrl("https://en.wikipedia.org");

// set HTTP response headers
Response.ContentType = "application/pdf";
Response.Headers.Add("Cache-Control", "max-age=0");
Response.Headers.Add("Accept-Ranges", "none");
Response.Headers.Add("Content-Disposition", "attachment; filename*=UTF-8''" + Uri.EscapeUriString("result.pdf"));

// send the result in the HTTP response
Response.OutputStream.Write(pdf, 0, pdf.Length);
Response.Flush();
// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and store the result into the "pdf" variable
byte [] pdf = client.convertUrl("https://en.wikipedia.org");

// set HTTP response headers
Response.ContentType = "application/pdf";
Response.Headers.Add("Cache-Control", "max-age=0");
Response.Headers.Add("Accept-Ranges", "none");
Response.Headers.Add("Content-Disposition", "attachment; filename*=UTF-8''" + Uri.EscapeUriString("result.pdf"));

// send the result in the HTTP response
Response.OutputStream.Write(pdf, 0, pdf.Length);
Response.Flush();
' create the API client instance
Dim client As New pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d")

' run the conversion and store the result into the "pdf" variable
Dim pdf() As Byte = client.convertUrl("https://en.wikipedia.org")

' set HTTP response headers
Response.ContentType = "application/pdf"
Response.Headers.Add("Cache-Control", "max-age=0")
Response.Headers.Add("Accept-Ranges", "none")
Response.Headers.Add("Content-Disposition", "attachment; filename*=UTF-8''" & Uri.EscapeUriString("result.pdf"))

' send the result in the HTTP response
Response.OutputStream.Write(pdf, 0, pdf.Length)
Response.Flush()
VB   C#

XMLをPDFに変換

次のコードはXMLをIronPDFおよびPDFCrowd API用のPDFに変換します。

7.1. IronPDFを使用してXMLをPDFに変換

C# での XML から PDF への直接変換は、複雑な課題となることがあります。 XMLをPDFにC#で変換する際には、XSLTから始めるのが最適であることがわかりました。 XMLはHTMLを介してPDFにレンダリングされる可能性があります。(5) XLST変換を使用して。

private void XMLtoPDF(string XSLT, string XML)
{
    XslCompiledTransform transform = new XslCompiledTransform();
    using(XmlReader reader = XmlReader.Create(new StringReader(XSLT)))  
    {
        transform.Load(reader);
    }
    StringWriter results = new StringWriter();
    using(XmlReader reader = XmlReader.Create(new StringReader(XML))) 
    {
        transform.Transform(reader, null, results);
    }
    IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
    // options, headers, and footers may be set there
    // Render our XML as a PDF via XSLT
    using var PDF = Renderer.RenderHtmlAsPdf(results.ToString())l
    PDF.SaveAs("XMLtoPDF.pdf");
}
private void XMLtoPDF(string XSLT, string XML)
{
    XslCompiledTransform transform = new XslCompiledTransform();
    using(XmlReader reader = XmlReader.Create(new StringReader(XSLT)))  
    {
        transform.Load(reader);
    }
    StringWriter results = new StringWriter();
    using(XmlReader reader = XmlReader.Create(new StringReader(XML))) 
    {
        transform.Transform(reader, null, results);
    }
    IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
    // options, headers, and footers may be set there
    // Render our XML as a PDF via XSLT
    using var PDF = Renderer.RenderHtmlAsPdf(results.ToString())l
    PDF.SaveAs("XMLtoPDF.pdf");
}
Private Sub XMLtoPDF(ByVal XSLT As String, ByVal XML As String)
	Dim transform As New XslCompiledTransform()
	Using reader As XmlReader = XmlReader.Create(New StringReader(XSLT))
		transform.Load(reader)
	End Using
	Dim results As New StringWriter()
	Using reader As XmlReader = XmlReader.Create(New StringReader(XML))
		transform.Transform(reader, Nothing, results)
	End Using
	Dim Renderer As New IronPdf.ChromePdfRenderer()
	' options, headers, and footers may be set there
	' Render our XML as a PDF via XSLT
	Dim PDF = Renderer.RenderHtmlAsPdf(results.ToString())l PDF.SaveAs("XMLtoPDF.pdf")
End Sub
VB   C#

XSLTファイルの構造は以下の通りです:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <p>Titles:
    <xsl:for-each select="catalog/cd">
      <xsl:value-of select="title"/>
      <xsl:if test="position() < last()-1">
        <xsl:text>, </xsl:text>
      </xsl:if>
      <xsl:if test="position()=last()-1">
        <xsl:text>, and </xsl:text>
      </xsl:if>
      <xsl:if test="position()=last()">
        <xsl:text>!</xsl:text>
      </xsl:if>
    </xsl:for-each>
    </p>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <p>Titles:
    <xsl:for-each select="catalog/cd">
      <xsl:value-of select="title"/>
      <xsl:if test="position() < last()-1">
        <xsl:text>, </xsl:text>
      </xsl:if>
      <xsl:if test="position()=last()-1">
        <xsl:text>, and </xsl:text>
      </xsl:if>
      <xsl:if test="position()=last()">
        <xsl:text>!</xsl:text>
      </xsl:if>
    </xsl:for-each>
    </p>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2> My CD Collection</h2> <p> Titles: <xsl:for-@each @select="catalog/cd"> <xsl:value-@of @select="title"/> <xsl:if test="position() < last()-1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:if test="position()=last()-1"> <xsl:text>, @and </xsl:text> </xsl:if> <xsl:if test="position()=last()"> <xsl:text>!</xsl:text> </xsl:if> </xsl:for-@each> </p> </body> </html> </xsl:template> </xsl:stylesheet>
VB   C#

XMLをPDFに変換するには、PDFCrowdを使用します。

PDFCrowd API クライアントは、HTMLテンプレートのレンダリングを可能にします。 テンプレート構文は、Jinjaテンプレートレンダリングエンジンに基づいています。XML形式はPDFCrowd APIクライアントによってもサポートされており、この構文と共に使用することができます。

// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("{{ user_name }}", "{{ api_key }}");

// configure the conversion
client.setDataString(@"<?xml version=""1.0"" encoding=""UTF-8""?>
        <data>
          <name>World</name>
          <product>Pdfcrowd API</product>
        </data>");

// run the conversion and write the result to a file
client.convertStringToFile("Hello {{ data.name }} from {{ data.product }}", "output.pdf");
// create the API client instance
pdfcrowd.HtmlToPdfClient client = new pdfcrowd.HtmlToPdfClient("{{ user_name }}", "{{ api_key }}");

// configure the conversion
client.setDataString(@"<?xml version=""1.0"" encoding=""UTF-8""?>
        <data>
          <name>World</name>
          <product>Pdfcrowd API</product>
        </data>");

// run the conversion and write the result to a file
client.convertStringToFile("Hello {{ data.name }} from {{ data.product }}", "output.pdf");
' create the API client instance
Dim client As New pdfcrowd.HtmlToPdfClient("{{ user_name }}", "{{ api_key }}")

' configure the conversion
client.setDataString("<?xml version=""1.0"" encoding=""UTF-8""?>
        <data>
          <name>World</name>
          <product>Pdfcrowd API</product>
        </data>")

' run the conversion and write the result to a file
client.convertStringToFile("Hello {{ data.name }} from {{ data.product }}", "output.pdf")
VB   C#

8. 画像をPDFに変換

8.1. IronPDFを使用して画像をPDFに変換

IronPDFライブラリでは、IronPdf.ImageToPdfConverterクラスを使用して、1つまたは複数の画像ファイルから簡単にPDFドキュメントを作成することができます。

// One or more images as IEnumerable.  This example selects all JPEG images in a specific folder.
var ImageFiles = System.IO.Directory.EnumerateFiles(@"C:\project\assets").Where(f => f.EndsWith(".jpg") 
 f.EndsWith(".jpeg"));

// Convert the images to a PDF and save it.
using var PDF = ImageToPdfConverter.ImageToPdf(ImageFiles);
PDF.SaveAs(@"C:\project\composite.pdf");

//Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
// One or more images as IEnumerable.  This example selects all JPEG images in a specific folder.
var ImageFiles = System.IO.Directory.EnumerateFiles(@"C:\project\assets").Where(f => f.EndsWith(".jpg") 
 f.EndsWith(".jpeg"));

// Convert the images to a PDF and save it.
using var PDF = ImageToPdfConverter.ImageToPdf(ImageFiles);
PDF.SaveAs(@"C:\project\composite.pdf");

//Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
IRON VB CONVERTER ERROR developers@ironsoftware.com
VB   C#

8.2. PDFCrowdを使用して画像をPDFに変換する

PDFCrowdは、さまざまなオプションを備えた画像をPDFに変換する機能も提供しています。 それに加えて、URLから画像を変換するオプションも提供しています。 次のコードは、ローカルストレージから画像をPDFに変換する方法を示しています。

// create the API client instance
pdfcrowd.ImageToPdfClient client = new pdfcrowd.ImageToPdfClient("your_username", "your_apikey");

// run the conversion and write the result to a file
client.convertFileToFile("/path/to/logo.png", "logo.pdf");
// create the API client instance
pdfcrowd.ImageToPdfClient client = new pdfcrowd.ImageToPdfClient("your_username", "your_apikey");

// run the conversion and write the result to a file
client.convertFileToFile("/path/to/logo.png", "logo.pdf");
' create the API client instance
Dim client As New pdfcrowd.ImageToPdfClient("your_username", "your_apikey")

' run the conversion and write the result to a file
client.convertFileToFile("/path/to/logo.png", "logo.pdf")
VB   C#

翻訳された内容は以下の通りです:

  1. ライセンス

PDFCrowdは、他の形式からオンラインでPDFファイルを作成するウェブサービスです。異なる価格体系があり、最も低価格のプランは月額11ドルで、200クレジットの制限があります。1クレジットは出力データの0.5Mbに相当します。 無料体験版にサインアップすることもできます。 詳細な価格は、こちらでご確認いただけます PDFCrowd の価格ページ.

一方、IronPDFはC#のPDFライブラリです。 開発用には無料で、商業展開には常にライセンスを取得することができます。 ライセンスが利用可能です 単一プロジェクトの使用、単一の開発者、代理店、およびグローバル企業、さらにSaaSおよびOEM再配布のために。 すべてのライセンスには以下が含まれます:30日間の返金保証、1年間の製品サポートと更新、開発/ステージング/プロダクションの有効性、そして永久ライセンス。 (一回限りの購入). Liteパッケージは $749から始まります。 IronPDFパッケージは永久であり、継続的なコストは発生しませんが、これに対し、PDFCrowdには継続的なコストがあります。

10. まとめと結論

サマリー

IronPDFはリモートサーバーからHTMLをPDFに変換しません。 実際には、バックグラウンドで標準的なウェブブラウザーのインスタンスを起動します。 (追加のソフトウェアをインストールする必要なしに). HTMLは完全に正確にレンダリングされ、商業印刷の最高基準に適したベクターフォーマットで提供されます。 出力はクリーンで高品質なPDFです。 ライセンスおよび価格の詳細がすべてウェブサイトに公開されているオープンな商用です。

PDFCrowdは、多数の場所にあるクラウドサーバー上で稼働するため、ダウンタイムが全くなく、任意の形式のHTMLを最高の精度でPDFに変換します。 PDFCrowdは、PDFへの変換を提供するオンラインサービスを提供するウェブベースのAPIです。 サーバーサイドAPIクライアントライブラリは、Pdfcrowd HTMLからPDF APIを簡単に使用できるようにします。 これらのライブラリは、さまざまな人気のサーバーサイドプログラミング言語で利用可能です。 価格の詳細はウェブサイトに記載されています。

結論

IronPDFは、一度インストールされるとオフラインでも動作するため、PDFCrowdよりわずかに優れています。 IronPDFは、効果的かつ効率的に作業を進めることを目指す実践的なプログラマーに強く推奨されます。 最も重要なことは、時間を節約できることです。 PDFCrowdは、さまざまなサーバーサイド言語でPDFを扱う際に役立ちます。 さらに、IronPDFパッケージは永久ライセンスを提供しており、継続的なコストはかかりません。一方、PDFCrowdには継続的なコストが発生します。

< 以前
Accusoft Prizmdoc PDF Viewer チュートリアルおよび比較
次へ >
IronPDFとDocraptor - 詳細な比較

準備はできましたか? バージョン: 2024.9 新発売

無料のNuGetダウンロード 総ダウンロード数: 10,659,073 View Licenses >