透かしなしで本番環境でテストしてください。
必要な場所で動作します。
30日間、完全に機能する製品をご利用いただけます。
数分で稼働させることができます。
製品トライアル期間中にサポートエンジニアリングチームへの完全アクセス
.NET Frameworkに最適なPDFツールをお探しですか?
この記事では、C#(最も人気のあるプログラミング言語の1つ)でPDFファイルを操作する方法を見ていきます。 私たちは、C#向けの .NET Framework 上で業界をリードする2つのPDFツールについて、パフォーマンスと機能に基づいてコードサンプルを使用して比較します。 最終的に、ライセンスの詳細を検討し、ライセンスキーの取得方法を学びます。
2つのPDFライブラリは:
IronPDFは、C# .NET開発者のためのPDF問題を解決する単一のライブラリとして、Iron Softwareによって開発されたC# .NETライブラリです。 IronPdfはクロミウムエンジンを搭載しており、HTML5、JavaScript、CSS、画像ファイルのPDFへの変換、カスタムヘッダーとカスタムフッターの作成、ブラウザで表示されるPDFの正確な表示など、様々な便利で強力な機能を備えています。 IronPDFは、PDFファイルからデータを読み取り、それを自動的に.NETアプリケーションやデータストレージシステムに挿入することができます。 古いPDFドキュメントストレージからコンテンツをインポート、移動、インデックス化して、ドキュメント管理およびビジネスアプリケーションに取り込むことができます。
この機能は、HTML、MVCビュー、Webフォーム、HTML文字列、およびURLなどのさまざまな形式からPDFファイルを生成することを可能にします。
多くの場合、PDFに埋め込まれたテキストを簡単に抽出できます。 しかし、それが失敗した場合、テキストはおそらく画像に埋め込まれている可能性があります。 ドキュメントをプレーンテキストではなく視覚的なテキストとしてスキャンするには、IronOCR ライブラリを使用します。
PDFの作成中または既存のPDFにヘッダーとフッターを追加することができます。 Print Optionsプロパティを使用して、各ドキュメントページにヘッダーとフッターを作成できます。 これらのパラメータはChromePdfRendererオブジェクトで利用可能です。 この例は、.NET Core コンソールアプリ内で実行されます。
これはユーザーが写真からPDFを生成したり、PDFから写真を生成したりすることを可能にします。画像の抽出、さまざまな画像形式、およびPDFの印刷をサポートしています。
IronPDFには、128ビットのPDF暗号化、パスワード保護付きのPDFロック、およびPDFのデジタル署名も含まれています。
IronPDFツールを使用すると、PDFにウォーターマークを追加したり、ページを追加・削除したり、背景や前景を追加したり、その他さまざまな操作を行うことができます。
IronPDFは、C#に対応するほぼすべてのオペレーティングシステムおよびフレームワークをサポートしています。次のようなものが含まれます:
PDFNet .NET SDK by PDFTronは、高精度のPDF処理、注釈付け、編集、作成機能をウェブ、モバイル、デスクトップ、サーバー上のあらゆるフレームワークやアプリケーションに提供します。 それは、インフラストラクチャと共に文書および情報管理プロセス全体を管理し、サードパーティのサーバー依存関係を不要にします。 PDFTronのウェブプラットフォームには、すべてのPDF SDK用にサポートされているプラットフォームとデモライセンスキーが含まれたJSバージョンが付属しています。
PDFNet の最も重要な利点の一つは、本当にクロスプラットフォームであることです。これにより、ユーザーは単一のインターフェースを使用するだけで、多種多様なモバイルやデスクトップのコンテキストにわたり、PDF 互換性と関連するビジネス機能をワークフローやアプリに簡単に追加できます。
PDFNet SDK は、多くのプラットフォームおよびフレームワークと互換性があります。 プラットフォームの一貫性を確保するために、JavaScript APIはPDFNet APIと同様に使用されます。 SDKのNode.jsおよびElectronバージョンも利用可能です。 このパッケージには非管理のアドオンバイナリが必要です。
オンライン、モバイル、デスクトッププラットフォーム全体のユーザーに、安全でスケーラブルかつ高忠実度のPDF読み取りおよび編集機能を提供します。
カスタマイズされた署名手順の作成 デジタル署名された文書は、認証、検証、捺印が可能です。
個人情報や個人の健康情報などの機密データを文書から削除しながら、文書を検索可能な状態に保ちます。
ページを追加、削除、または並べ替えることができます。 ドキュメントは、組み立て、マージ、または分割することができます。 複数の文書を同じリーダーで同時に表示するか、並べて表示します。
この記事では、コンソールアプリケーションを使用してPDFドキュメントを生成します。
Visual Studioソフトウェアを開き、[ファイル]メニューに移動します。 「新しいプロジェクト」を選択し、次に「コンソール アプリケーション」を選択してください。
プロジェクト名を入力し、適切なテキストボックスにパスを選択してください。 次に、「Create」ボタンをクリックしてください。 以下のスクリーンショットのように、必要な.NETフレームワークを選択してください:
Visual Studioプロジェクトは、これからコンソールアプリケーションの構造を生成します。 完了すると、program.cs
ファイルが開かれ、その中でソースコードの記述と実行が可能になります。
ライブラリを追加して、プログラムをテストすることができます。
IronPDFライブラリは、4つの異なる方法でダウンロードおよびインストールできます。 これらは:
Visual Studioソフトウェアは、ソリューションにパッケージを直接インストールするためのNuGetパッケージマネージャーオプションを提供します。 以下のスクリーンショットは、NuGetパッケージマネージャーの開き方を示しています。
パッケージマネージャーGUIを開いたら、[ブラウズ]タブをクリックし、「IronPDF」を検索してください。
上記の画像では、検索結果に関連したパッケージの一覧が表示されています。 IronPDFオプションを選択し、パッケージをソリューションにインストールします。
Visual Studio メニューで、ツール > NuGet パッケージ マネージャー > パッケージ マネージャー コンソールに移動します。
Install-Package IronPdf
IronPDFパッケージがプロジェクトにインストールされます。
3番目の方法は、NuGet Gallery IronPDF Packageから直接NuGetパッケージをダウンロードすることです。
最新パッケージをIronPDFダウンロードページから直接ダウンロードしてください。 ダウンロード後、以下の手順に従ってパッケージをプロジェクトに追加してください。
PDFNet SDKは、4つの異なる方法でダウンロードおよびインストールできます。
上記の説明に従い、Visual Studio のツールに移動して NuGet パッケージ マネージャーを開いてください。 ソリューションのNuGetパッケージの管理をクリックしてください。
検索バー付きのウィンドウが表示されます。 プロジェクトにPDFNetを検索してインストールしてください。
Install-Package PDFNet ---Version 9.2.0
3つ目の方法は、NuGet Gallery PDFNet Packageから直接NuGetパッケージをダウンロードすることです。
PDFNet API は、PDFNetLoader.dll ファイルを使用してインストールすることもできます。GitHub Releases for PDFNetLoader.dllからダウンロードしてください。
パッケージをダウンロードし、プロジェクトのbinファイルに配置して実行してください。 あなたのVisual Studioプロジェクトに、PDFNetLoader.dllを参照として追加してください。
PDFファイルを印刷することは、PDFを扱う現代のアプリケーションにとって必要不可欠な機能です。 ここでは、両方のツールを使用してPDFファイルを印刷する方法について説明します。
IronPDFは、PDFをコンピュータのデフォルトプリンタに送信することで印刷します。 Windowsの印刷インターフェイスが開きますので、印刷をクリックしてください。
using IronPdf;
// Create a new PDF and print it
var Renderer = new IronPdf.ChromePdfRenderer();
PdfDocument Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Send the PDF to the default printer to print
Pdf.Print(300, false);
using IronPdf;
// Create a new PDF and print it
var Renderer = new IronPdf.ChromePdfRenderer();
PdfDocument Pdf = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Send the PDF to the default printer to print
Pdf.Print(300, false);
Imports IronPdf
' Create a new PDF and print it
Private Renderer = New IronPdf.ChromePdfRenderer()
Private Pdf As PdfDocument = Renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
' Send the PDF to the default printer to print
Pdf.Print(300, False)
PDFTronのPDFNet SDKは印刷機能も提供しています。 以下は、PDFNetでPDFファイルを印刷するためのソースコードスニペットです。
using System;
using System.Drawing;
using System.Drawing.Printing;
using pdftron;
using pdftron.PDF;
using pdftron.Common;
using pdftron.Filters;
namespace PDFPrintTestCS
{
Console.WriteLine("Opening the input file...");
using (pdfdoc = new PDFDoc(input_path + "tiger.pdf"))
{
pdfdoc.InitSecurityHandler();
Console.WriteLine("Printing the input file using PDF.Print.StartPrintJob...");
PrinterMode printerMode = new PrinterMode();
printerMode.SetAutoCenter(true);
printerMode.SetAutoRotate(true);
printerMode.SetCollation(true);
printerMode.SetCopyCount(1);
printerMode.SetDPI(300); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode.DuplexMode.e_Duplex_Auto);
printerMode.SetNUp(PrinterMode.NUp.e_NUp_1_1, PrinterMode.NUpPageOrder.e_PageOrder_LeftToRightThenTopToBottom);
printerMode.SetOrientation(PrinterMode.Orientation.e_Orientation_Portrait);
printerMode.SetOutputAnnot(PrinterMode.PrintContentTypes.e_PrintContent_DocumentAndAnnotations);
printerMode.SetOutputColor(PrinterMode.OutputColor.e_OutputColor_Grayscale);
printerMode.SetOutputPageBorder(false);
printerMode.SetOutputQuality(PrinterMode.OutputQuality.e_OutputQuality_Medium);
printerMode.SetPaperSize(new Rect(0, 0, 612, 792));
PageSet pagesToPrint = new PageSet(1, pdfdoc.GetPageCount(), PageSet.Filter.e_all);
Print.StartPrintJob(pdfdoc, "", pdfdoc.GetFileName(), "", pagesToPrint, printerMode, null);
}
}
using System;
using System.Drawing;
using System.Drawing.Printing;
using pdftron;
using pdftron.PDF;
using pdftron.Common;
using pdftron.Filters;
namespace PDFPrintTestCS
{
Console.WriteLine("Opening the input file...");
using (pdfdoc = new PDFDoc(input_path + "tiger.pdf"))
{
pdfdoc.InitSecurityHandler();
Console.WriteLine("Printing the input file using PDF.Print.StartPrintJob...");
PrinterMode printerMode = new PrinterMode();
printerMode.SetAutoCenter(true);
printerMode.SetAutoRotate(true);
printerMode.SetCollation(true);
printerMode.SetCopyCount(1);
printerMode.SetDPI(300); // regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode.DuplexMode.e_Duplex_Auto);
printerMode.SetNUp(PrinterMode.NUp.e_NUp_1_1, PrinterMode.NUpPageOrder.e_PageOrder_LeftToRightThenTopToBottom);
printerMode.SetOrientation(PrinterMode.Orientation.e_Orientation_Portrait);
printerMode.SetOutputAnnot(PrinterMode.PrintContentTypes.e_PrintContent_DocumentAndAnnotations);
printerMode.SetOutputColor(PrinterMode.OutputColor.e_OutputColor_Grayscale);
printerMode.SetOutputPageBorder(false);
printerMode.SetOutputQuality(PrinterMode.OutputQuality.e_OutputQuality_Medium);
printerMode.SetPaperSize(new Rect(0, 0, 612, 792));
PageSet pagesToPrint = new PageSet(1, pdfdoc.GetPageCount(), PageSet.Filter.e_all);
Print.StartPrintJob(pdfdoc, "", pdfdoc.GetFileName(), "", pagesToPrint, printerMode, null);
}
}
Imports System
Imports System.Drawing
Imports System.Drawing.Printing
Imports pdftron
Imports pdftron.PDF
Imports pdftron.Common
Imports pdftron.Filters
Namespace PDFPrintTestCS
Console.WriteLine("Opening the input file...")
pdfdoc = New PDFDoc(input_path & "tiger.pdf")
Using pdfdoc
pdfdoc.InitSecurityHandler()
Console.WriteLine("Printing the input file using PDF.Print.StartPrintJob...")
Dim printerMode As New PrinterMode()
printerMode.SetAutoCenter(True)
printerMode.SetAutoRotate(True)
printerMode.SetCollation(True)
printerMode.SetCopyCount(1)
printerMode.SetDPI(300) ' regardless of ordering, an explicit DPI setting overrides the OutputQuality setting
printerMode.SetDuplexing(PrinterMode.DuplexMode.e_Duplex_Auto)
printerMode.SetNUp(PrinterMode.NUp.e_NUp_1_1, PrinterMode.NUpPageOrder.e_PageOrder_LeftToRightThenTopToBottom)
printerMode.SetOrientation(PrinterMode.Orientation.e_Orientation_Portrait)
printerMode.SetOutputAnnot(PrinterMode.PrintContentTypes.e_PrintContent_DocumentAndAnnotations)
printerMode.SetOutputColor(PrinterMode.OutputColor.e_OutputColor_Grayscale)
printerMode.SetOutputPageBorder(False)
printerMode.SetOutputQuality(PrinterMode.OutputQuality.e_OutputQuality_Medium)
printerMode.SetPaperSize(New Rect(0, 0, 612, 792))
Dim pagesToPrint As New PageSet(1, pdfdoc.GetPageCount(), PageSet.Filter.e_all)
Print.StartPrintJob(pdfdoc, "", pdfdoc.GetFileName(), "", pagesToPrint, printerMode, Nothing)
End Using
End Namespace
両方のライブラリはHTMLからPDFへの変換機能を持っていますが、その方法は少し異なります。
IronPDFはJSONや暗号化メカニズムの使用を必要としません。 IronPDFは幅広いメソッドをサポートしています。 例えば:
using IronPdf;
var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf");
using IronPdf;
var Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf");
Imports IronPdf
Private Renderer = New IronPdf.ChromePdfRenderer()
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").SaveAs("pixel-perfect.pdf")
using IronPdf;
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
using IronPdf;
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
Imports IronPdf
Private Renderer As New IronPdf.ChromePdfRenderer()
Private Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
Pdf.SaveAs("url.pdf")
PDFNetは、ページ変換とURL変換の両方を使用して、HTMLからPDFへの変換機能も提供します。 コードが長いため、ここでは一例のみを紹介します。
class HTML2PDFSample
{
private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
static HTML2PDFSample() {}
static void Main(string [] args)
{
string output_path = "../../../../TestFiles/Output/html2pdf_example";
string host = "https://www.pdftron.com";
string page0 = "/";
string page1 = "/support";
string page2 = "/blog";
HTML2PDF.SetModulePath("../../../../../Lib");
if (!HTML2PDF.IsModuleAvailable())
{
Console.WriteLine();
Console.WriteLine("Unable to run HTML2PDFTest: PDFTron SDK HTML2PDF module not available.");
Console.WriteLine("-------------------------------");
Console.WriteLine("The HTML2PDF module is an optional add-on, available for download");
Console.WriteLine("at http://www.pdftron.com/. If you have already downloaded this");
Console.WriteLine("module, ensure that the SDK is able to find the required files");
Console.WriteLine("using the HTML2PDF.SetModulePath() function.");
Console.WriteLine();
return;
}
try
{
using (PDFDoc doc = new PDFDoc())
{
if ( HTML2PDF.Convert(doc, host + page0) )
doc.Save(output_path + "_01.pdf", SDFDoc.SaveOptions.e_linearized);
else
Console.WriteLine("Conversion failed.");
}
}
catch (PDFNetException e)
{
Console.WriteLine(e.Message);
}
}
}
class HTML2PDFSample
{
private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
static HTML2PDFSample() {}
static void Main(string [] args)
{
string output_path = "../../../../TestFiles/Output/html2pdf_example";
string host = "https://www.pdftron.com";
string page0 = "/";
string page1 = "/support";
string page2 = "/blog";
HTML2PDF.SetModulePath("../../../../../Lib");
if (!HTML2PDF.IsModuleAvailable())
{
Console.WriteLine();
Console.WriteLine("Unable to run HTML2PDFTest: PDFTron SDK HTML2PDF module not available.");
Console.WriteLine("-------------------------------");
Console.WriteLine("The HTML2PDF module is an optional add-on, available for download");
Console.WriteLine("at http://www.pdftron.com/. If you have already downloaded this");
Console.WriteLine("module, ensure that the SDK is able to find the required files");
Console.WriteLine("using the HTML2PDF.SetModulePath() function.");
Console.WriteLine();
return;
}
try
{
using (PDFDoc doc = new PDFDoc())
{
if ( HTML2PDF.Convert(doc, host + page0) )
doc.Save(output_path + "_01.pdf", SDFDoc.SaveOptions.e_linearized);
else
Console.WriteLine("Conversion failed.");
}
}
catch (PDFNetException e)
{
Console.WriteLine(e.Message);
}
}
}
Friend Class HTML2PDFSample
Private Shared pdfNetLoader As pdftron.PDFNetLoader = pdftron.PDFNetLoader.Instance()
Shared Sub New()
End Sub
Shared Sub Main(ByVal args() As String)
Dim output_path As String = "../../../../TestFiles/Output/html2pdf_example"
Dim host As String = "https://www.pdftron.com"
Dim page0 As String = "/"
Dim page1 As String = "/support"
Dim page2 As String = "/blog"
HTML2PDF.SetModulePath("../../../../../Lib")
If Not HTML2PDF.IsModuleAvailable() Then
Console.WriteLine()
Console.WriteLine("Unable to run HTML2PDFTest: PDFTron SDK HTML2PDF module not available.")
Console.WriteLine("-------------------------------")
Console.WriteLine("The HTML2PDF module is an optional add-on, available for download")
Console.WriteLine("at http://www.pdftron.com/. If you have already downloaded this")
Console.WriteLine("module, ensure that the SDK is able to find the required files")
Console.WriteLine("using the HTML2PDF.SetModulePath() function.")
Console.WriteLine()
Return
End If
Try
Using doc As New PDFDoc()
If HTML2PDF.Convert(doc, host & page0) Then
doc.Save(output_path & "_01.pdf", SDFDoc.SaveOptions.e_linearized)
Else
Console.WriteLine("Conversion failed.")
End If
End Using
Catch e As PDFNetException
Console.WriteLine(e.Message)
End Try
End Sub
End Class
IronPDFは、無料の開発者ライセンスを提供するライブラリです。 IronPDFは特別な価格構造も提供しています: ライトパッケージは隠れたコストなしで$749から始まります。 SaaSおよびOEM製品を再配布することも可能です。 すべてのライセンスには、30日間の返金保証、1年間のソフトウェアサポートとアップグレード、開発/テスト/ステージング/本番環境での有効性、および永続ライセンス(一度限りの購入)が含まれています。 IronPDFのライセンスは、ユーザーのニーズに最大限のパフォーマンスを提供します。 このIronPDFライセンスページにアクセスして、IronPDFの価格構造とライセンスのすべてを確認してください。
PDFTron PDFNet SDKは、お客様のビジネスニーズに合わせた複数のライセンス選択肢を提供しています。 エンタープライズおよびOEM再配布には、3種類のライセンスが付属しています。 企業ライセンスは組織の使用のみを目的としており、アプリ配布には使用できません。 追加のAPIがファイルシステムアクセスを必要とする場合、ライセンスに含まれています。 すべてのライセンスにはライセンスキーが付属しています。 ライセンスの3種類は
コアSDK
ライセンス構造の詳細については、こちらのPDFTronライセンス情報ページをご覧ください。
IronPDFは、PDFファイルを処理し、さまざまな形式に変換するための多くの機能と機能を提供します。 HTMLからPDFへの変換は、高品質の商業印刷に適したベクターフォーマットで生成されます。 その結果、クリアで高品質なPDFを受け取ることができます。 ライセンスおよび価格情報はウェブサイトでご覧いただけます。
IronPDFと同様に、PDFNetはPDFファイルの移行、注釈、署名、記入、変換、および編集を支援します。 Windows、iOS、Android、WEBおよびLinuxを含む複数のプラットフォームをサポートしています。 実稼働用途には、PDFNet SDKに製品キーが必要です。
IronPDFのライセンスは開発者中心であり、製品を使用する開発者の数に基づいてライセンスを取得する必要があります。 一方、PDFNetライセンスは同じ方法では機能せず、代わりに機能ベースのライセンスで動作します。 これは、必要な機能をサポートするライセンスを取得する必要があることを意味します。 IronPDFのライセンスには、すべての機能が標準で含まれています。 PDFNetでは、ドキュメント変換などの一部の機能は、アドオンとして購入する必要があります。
IronPDFライブラリは機能を整理された形で提供しており、少ないコード行数で大きなタスクを実行するコードを書くことが簡単です。 Iron Softwareは現在、5つのツールパッケージを2つの価格で提供しています。 Suite に含まれるツールは次のとおりです:
このIron Suite 情報ページを訪れて、Iron Suite を探求してください。