製品比較

ActivePDF DocConverterチュートリアルとIronPDFとの比較

ActivePDF Toolkitは、PDFファイルを操作するために使用されるソフトウェアコンポーネントであり、異なるソースからPDFファイルを生成し、ヘッダー、フッター、余白、またはウォーターマークのようなプロパティを設定します。

IronPDFは、競争力のある価格設定の<C# PDF Library>でこれらの機能も提供します。

ここでは、.NET Visual Studio プロジェクトで両方のソフトウェアコンポーネントを使用するための機能、コード例、および段階的な手順について説明します。これにより、アプリケーションに最適なものを自分で判断することができます。


概要

IronPDF C#ライブラリについて

Iron Softwareは、市場をリードするコンポーネントプロバイダーであり、PDFファイルの操作に使用するためにIronPDFを提供しています。 異なるフォーマットからPDFファイルを簡単に生成し、すべてのプロパティをプログラムで設定する包括的な方法。 これは、わずか数行のコードで一貫性があり、信頼性が高く、正確なPDFファイルを出力するため、開発者に好まれています。

IronPDFは、C#、.NET、VB、ASPX、ASP.NET、MVC、.NET Core用に設計されています。 Visual Studio、NuGet、Linux、Azure、Dockerなどに対応しています。

ActivePDF Toolkitについて ActivePDF Toolkitは、企業や開発者がPDFドキュメントの生成、操作、および操作を簡単に行うための強力なツールです。このツールを使用することで、PDFファイルの結合、分割、ページの抽出、フォームデータの入力、デジタル署名の追加など、さまざまな操作をプログラム的に行うことができます。ActivePDF Toolkitは、PDFの操作性を強化する柔軟なAPIを提供し、ワークフローの効率化と自動化を支援します。 主な機能には以下が含まれます: - PDFの生成と編集 - ページの再編成と操作 - フォーム処理とデジタル署名の追加 - 多様なプログラミング言語との互換性 - 安全なPDF操作と高度なセキュリティ機能 ActivePDF Toolkitは、あらゆる業種や用途に対応し、高品質なPDFソリューションを提供します。

ActivePDFは、PDFファイルを処理するための多くのコンポーネントを提供するソフトウェア会社です。 単一コンポーネントであるIronPDFとは異なり、ActivePDFはPDFファイルに対して異なるソリューションを提供します。 例えば、PDFファイルのサイズを削減するには、ActivePDF Compressorを使用できます。 HTMLソースからPDFを作成するには、ActivePDF WebGrabberを使用します。

この記事では、IronPDFと比較するためにActivePDF WebGrabberを使用します。それでは見てみましょう:

PDF作成用のActivePDF WebGrabber

ActivePDF WebGrabber は、URL、HTMLファイル、またはHTML文字列のようなHTMLソースからPDFファイルを生成するために特化したActivePDFの別コンポーネントです。 また、PDFファイルをニーズに合わせて作成するために、ヘッダー、フッター、マージン、透かし文字、ブックマークなどのページ属性を設定する機能も提供します。


比較

1. ActivePDFとIronPDFの比較表

両方のコンポーネントを並べて比較してみましょう。

IronPDF ActivePDF
IronPDF converts HTML sources to PDF files. ActivePDF converts HTML sources to PDF files.
IronPDF supports .NET Core. ActivePDF does not support .NET Core.
IronPDF supports .NET 4.0 or higher. ActivePDF supports .NET 4.6.2 or higher.
IronPDF supports macOS. ActivePDF does not support macOS.
IronPDF can apply CSS to set WaterMark properties. ActivePDF does not support CSS to set WaterMark properties.
IronPDF can set Paper Orientation of PDF files. ActivePDF can set Paper Orientation of PDF files.
IronPDF provides the RenderDelay function to delay the PDF conversion. ActivePDF provides the TimeoutSpan function to delay the PDF conversion.
IronPDF provides predefined functions to set Header or Footer. ActivePDF requires setting Header and Footer by raw HTML and CSS.
IronPDF provides a predefined function to draw a horizontal line to separate content. ActivePDF does not provide a line to separate headers and footers.
To save the PDF file, we can set the directory and file name in one line. We have to set file directory and file name separately.
Need to write fewer lines of code with a simple programming structure. Need to write many lines of code.
License starts from $749. License starts from $1180.

ステップ1:インストール

2. IronPDFのインストール方法

あなたのプロジェクトにIronPDFライブラリを2種類の方法で追加することができます。

NuGet パッケージマネージャー

  • Visual Studio プロジェクトで NuGet パッケージ マネージャーを開きます。
  • IronPDFを検索してインストールしてください。

    あるいは:

  • tools に移動します
  • パッケージ マネージャー コンソールを選択
  • 次のコマンドを実行します:
Install-Package IronPdf

IronPDF.dll を手動でダウンロード

私たちはまた、IronPDF.dllをダウンロードして、プロジェクトにリファレンスを追加することができます。

名前空間としてusing IronPdf;を記述してIronPDFにアクセスできる場合、それはIronPDFがプロジェクトに正常にインポートされ、使用準備が整っていることを意味します。


WebGrabberのインストール方法 1. WebGrabberのダウンロード: 公式サイト(https://ironpdf.com)にアクセスし、最新バージョンの「WebGrabber」をダウンロードしてください。ダウンロードリンクは製品ページにあります。 2. インストール: ダウンロードしたファイルを実行し、インストールウィザードの指示に従ってWebGrabberをインストールします。必要に応じて、インストールディレクトリを指定してください。 3. 開発環境の設定: IronPDF for .NET、IronOCR for .NET、IronXL for .NETのような他のIron Software製品と同様に、WebGrabberを使用するプロジェクトに追加します。通常、Visual StudioなどのIDEを使用します。 4. APIキーの取得: WebGrabberのAPIを利用するには、有効なAPIキーが必要です。公式サイトの「マイアカウント」ページからAPIキーを取得してください。 5. サンプルコードの実行: WebGrabberを正しくインストールしたか確認するために、提供されているサンプルコードを実行します。サンプルコードは公式ドキュメントや製品ページにあります。適切なAPIキーをコードに追加し、実行してください。 これでインストールは完了です。詳細な使用方法は公式サイトのドキュメントをご参照ください。

WebGrabber-install.exeをダウンロードし、ダウンロードファイルを選択してください。 ダウンロードが完了したら、ダウンロードしたファイルをダブルクリックしてください。 次に、以下の15日間の評価キーを使用するためのアクティベーションキーをActivePDFにリクエストしてください:001-AEALX-LC6Z5-7YD95-S3D8J-3LR25。

インストールが完了したら、次のディレクトリに移動してください:

C:\Program Files\ActivePDF\WebGrabber\bin\

このディレクトリでは、APWebGrabber.Net45.dll ファイルを入手できます。このファイルの参照をVisual Studioプロジェクトに追加してください。

さて、using APWebGrabber;名前空間を書いてWebGrabberにアクセスできる場合、それはActivePDF WebGrabberがプロジェクトに正常にインポートされ、利用可能であることを意味します。

ActivePDF ドキュメント は、ActivePDF WebGrabber のインストールについて詳しく学ぶために利用できます。


チュートリアルの方法

IronPDF および WebGrabber を使用する

これら二つのコンポーネントの導入およびインストールプロセスを見てきましたので、次に両者を使用して異なるタスクを実行しながら比較を始めます。 これにより、両方のプログラミング構造を理解し、私たちのプロジェクトにとってどちらが最適かを判断することができます。 より良い理解のために、各タスクで特定のユースケースを実行し、実装に使用されるコードを提供します。


3. HTML文字列をPDFファイルに変換

最初の比較では、HTML文字列を使用してPDFファイルを作成し、それを対象の場所に保存するケースを取り上げます。 まず、IronPDFを使ってこのユースケースを実装し始めます:

3.1. IronPDFを用いたHTML文字列

/**
HTML String to PDF
anchor-html-string-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new ChromePdfRenderer();
    //HTML Source
    string html = "<h1>Hello World!</h1> <h2>Welcome to IronPDF</h2> ";
    //convert HTML string to PDF file
    using var PDF = converter.RenderHtmlAsPdf(html);
    //Save the file
    PDF.SaveAs("E:/sample.pdf");
}
/**
HTML String to PDF
anchor-html-string-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new ChromePdfRenderer();
    //HTML Source
    string html = "<h1>Hello World!</h1> <h2>Welcome to IronPDF</h2> ";
    //convert HTML string to PDF file
    using var PDF = converter.RenderHtmlAsPdf(html);
    //Save the file
    PDF.SaveAs("E:/sample.pdf");
}
'''
'''HTML String to PDF
'''anchor-html-string-with-ironpdf
'''*
Imports IronPdf
Shared Sub Main(ByVal args() As String)
	'create rendering converter
	Dim converter = New ChromePdfRenderer()
	'HTML Source
	Dim html As String = "<h1>Hello World!</h1> <h2>Welcome to IronPDF</h2> "
	'convert HTML string to PDF file
	Dim PDF = converter.RenderHtmlAsPdf(html)
	'Save the file
	PDF.SaveAs("E:/sample.pdf")
End Sub
$vbLabelText   $csharpLabel

出力:

上記のコードは、Local Disk E:sample.pdf というPDFファイルを作成し、そのスクリーンショットは次のようになります:

Iron1 related to 3.1. IronPDFを用いたHTML文字列

3.2. アクティブPDFを用いたHTML文字列

using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //HTML Source
    string html = "<h1>Hello World!</h1> <h2>Welcome to ActivePDF WebGrabber</h2>";
    //assign source html to WebGrabber
    wg.CreateFromHTMLText = html;
    //specify file directory
    wg.OutputDirectory = "E:/";
    // file name
    wg.NewDocumentName = "sample.pdf";
    //convert source HTML to PDF file
    wg.ConvertToPDF();
}
using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //HTML Source
    string html = "<h1>Hello World!</h1> <h2>Welcome to ActivePDF WebGrabber</h2>";
    //assign source html to WebGrabber
    wg.CreateFromHTMLText = html;
    //specify file directory
    wg.OutputDirectory = "E:/";
    // file name
    wg.NewDocumentName = "sample.pdf";
    //convert source HTML to PDF file
    wg.ConvertToPDF();
}
Imports APWebGrabber
Shared Sub Main(ByVal args() As String)
	'Instantiate Object
	Dim wg As New WebGrabber()
	'HTML Source
	Dim html As String = "<h1>Hello World!</h1> <h2>Welcome to ActivePDF WebGrabber</h2>"
	'assign source html to WebGrabber
	wg.CreateFromHTMLText = html
	'specify file directory
	wg.OutputDirectory = "E:/"
	' file name
	wg.NewDocumentName = "sample.pdf"
	'convert source HTML to PDF file
	wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

次のスクリーンショットは、このコードから新しく生成されたsample.pdfファイルです。

Active1 related to 3.2. アクティブPDFを用いたHTML文字列

3.3. IronPDFとActivePDFの違い

  • IronPDFを使用してコード行数を削減
  • IronPDFで生成されたファイルは、デフォルトの余白のおかげでより読みやすくなっています。

HTMLファイルをPDFファイルに変換

この比較では、E:/ディレクトリに存在するmyHtmlFile.htmlという名前のHTMLファイルからPDFファイルを生成するケースを取り上げ、そのファイルには以下のHTMLとCSSコードがあります。

<html>
  <style>
        li{
            font-size:x-large;
            color: magenta;
            font-style: italic;
            }
  </style>
<body>
    <h1>I am Heading</h1>
    <h2>Items List:</h2>
    <ul>
        <li>Item1</li>
        <li>Item2</li>
        <li>Item3</li>
        <li>Item4</li>
    </ul>
</body>
</html>
<html>
  <style>
        li{
            font-size:x-large;
            color: magenta;
            font-style: italic;
            }
  </style>
<body>
    <h1>I am Heading</h1>
    <h2>Items List:</h2>
    <ul>
        <li>Item1</li>
        <li>Item2</li>
        <li>Item3</li>
        <li>Item4</li>
    </ul>
</body>
</html>
HTML

次に、両方のコンポーネントを使用してmyHtmlFile.htmlファイルをPDFファイルに変換します。 IronPDFから始めましょう。

4.1. IronPDFを使用したHTMLファイル

/**
HTML File to PDF
anchor-html-file-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new IronPdf.ChromePdfRenderer();
    //render html file to pdf
    using var PDF = converter.RenderHTMLFileAsPdf("E:/myHtmlFile.html");
    //save to target location
    PDF.SaveAs("E:/Sample.pdf");
}
/**
HTML File to PDF
anchor-html-file-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new IronPdf.ChromePdfRenderer();
    //render html file to pdf
    using var PDF = converter.RenderHTMLFileAsPdf("E:/myHtmlFile.html");
    //save to target location
    PDF.SaveAs("E:/Sample.pdf");
}
'''
'''HTML File to PDF
'''anchor-html-file-with-ironpdf
'''*
Imports IronPdf
Shared Sub Main(ByVal args() As String)
	'create rendering converter
	Dim converter = New IronPdf.ChromePdfRenderer()
	'render html file to pdf
	Dim PDF = converter.RenderHTMLFileAsPdf("E:/myHtmlFile.html")
	'save to target location
	PDF.SaveAs("E:/Sample.pdf")
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードを使用して新たに生成されたSample.pdfファイルです。

Iron2 related to 4.1. IronPDFを使用したHTMLファイル

HTMLページmyHtmlFile.htmlがPDFファイルSample.pdfに正常に変換され、CSSスタイルも適用されていることが確認できます。

IronPDFのドキュメントを読むと、.NETプロジェクトでのIronPDFの使い方について詳しくわかります。

ActivePDF WebGrabberを使用して同じタスクを実行しましょう。

4.2. HTMLファイルとActivePDF

using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //specify file path to be converted
    wg.URL = "E:/myHtmlFile.html";
    //specify the directory for newly generated file
    wg.OutputDirectory = "E:/";
    //newly generated file name
    wg.NewDocumentName = "Sample.pdf";
    //convert HTML file to PDF
    wg.ConvertToPDF();
}
using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //specify file path to be converted
    wg.URL = "E:/myHtmlFile.html";
    //specify the directory for newly generated file
    wg.OutputDirectory = "E:/";
    //newly generated file name
    wg.NewDocumentName = "Sample.pdf";
    //convert HTML file to PDF
    wg.ConvertToPDF();
}
Imports APWebGrabber
Shared Sub Main(ByVal args() As String)
	'Instantiate Object
	Dim wg As New WebGrabber()
	'specify file path to be converted
	wg.URL = "E:/myHtmlFile.html"
	'specify the directory for newly generated file
	wg.OutputDirectory = "E:/"
	'newly generated file name
	wg.NewDocumentName = "Sample.pdf"
	'convert HTML file to PDF
	wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードを使用して新たに生成されたSample.pdfファイルです。

Active2 related to 4.2. HTMLファイルとActivePDF

4.3. IronPDFとActivePDFの違い

  • IronPDFを使ったわずか3行のコード
  • IronPDF製のファイルはよりクリーンで魅力的です。

URLをPDFファイルに変換

URL https://yandex.com/ を例として、そのウェブページのPDFファイルを生成したいとしましょう。 そのためには、両方のコンポーネントが機能を提供します。 まず、IronPDFを使用してどのように行うかを見てみましょう。

5.1. IronPDFでURLを取得

/**
URL to PDF
anchor-url-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new ChromePdfRenderer();
    //Specify URL
    using var PDF = converter.RenderUrlAsPdf("https://yandex.com/");
    //Save the file
    PDF.SaveAs("E:/Sample.pdf");
}
/**
URL to PDF
anchor-url-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new ChromePdfRenderer();
    //Specify URL
    using var PDF = converter.RenderUrlAsPdf("https://yandex.com/");
    //Save the file
    PDF.SaveAs("E:/Sample.pdf");
}
'''
'''URL to PDF
'''anchor-url-with-ironpdf
'''*
Imports IronPdf
Shared Sub Main(ByVal args() As String)
	'create rendering converter
	Dim converter = New ChromePdfRenderer()
	'Specify URL
	Dim PDF = converter.RenderUrlAsPdf("https://yandex.com/")
	'Save the file
	PDF.SaveAs("E:/Sample.pdf")
End Sub
$vbLabelText   $csharpLabel

次のスクリーンショットは、上記のコードによって新たに生成されたSample.pdfファイルです。

Iron3 related to 5.1. IronPDFでURLを取得

IronPDFファイルの正確さがどの程度一致しているかを比較するために、URLサンプルのウェブページを訪れることができます。

では、次にActivePDF WebGrabberを使用して同じタスクを行います。

5.2. URL with ActivePDF

5.2. ActivePDFを使用したURL

using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //specify URL 
    wg.URL = "https://yandex.com/";
    //specify the directory for newly generated file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert specified URL webpage to PDF
    wg.ConvertToPDF();
}
using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //specify URL 
    wg.URL = "https://yandex.com/";
    //specify the directory for newly generated file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert specified URL webpage to PDF
    wg.ConvertToPDF();
}
Imports APWebGrabber
Shared Sub Main(ByVal args() As String)
	'Instantiate Object
	Dim wg As New WebGrabber()
	'specify URL 
	wg.URL = "https://yandex.com/"
	'specify the directory for newly generated file
	wg.OutputDirectory = "E:/"
	'specify file name
	wg.NewDocumentName = "Sample.pdf"
	'convert specified URL webpage to PDF
	wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードによって新しく生成されたSample.pdfファイルです。

Active3 related to 5.2. URL with ActivePDF

5.3. IronPDF と ActivePDF の違い

  • IronPDFはPDFファイルを生成するためのよりシンプルな構造を持っています。
  • 3行のコードだけ
  • IronPDFはサイトにぴったりマッチします

6.PDFに透かしを入れる

この比較では、HTML文字列を使用してPDFファイルを作成し、その後、ページの中央にウォーターマークを追加します。 IronPDFから始めましょう。

6.1. IronPDFによるウォーターマーク

IronPDFは、次の機能を提供してウォーターマークを追加します:

WatermarkPage(WaterMark HTML String, PageIndexToWaterMark, WaterMarkLocation, Opacity, Rotation, Hyperlink)

WaterMarkLocation を使用して、次の位置にウォーターマークを設定できます:

  • 左上

  • 中央上部

  • 右上

  • 中央左

  • 中央

  • 右中

  • ボトム左

  • ボトムセンター

  • 右下

    上記の機能を使用してウォーターマークを設定する方法を見てみましょう。

/**
Watermark PDF
anchor-watermark-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new ChromePdfRenderer();
    //source html string
    string html = "<h1 style='text-align:center'>WaterMark Example</h1>";
    //add above string as PDF file content
    using var PDF = converter.RenderHtmlAsPdf(html);
    //HTML string for WaterMark
    string WMStr = "<h1 style='color:red'>WaterMark</h1>";
    //add WaterMark
    PDF.WatermarkPage(WMStr, 0, PdfDocument.WaterMarkLocation.MiddleCenter, 100, -45, "");
    //save the document
    PDF.SaveAs("E:/Sample.pdf");
}
/**
Watermark PDF
anchor-watermark-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create rendering converter
    var converter = new ChromePdfRenderer();
    //source html string
    string html = "<h1 style='text-align:center'>WaterMark Example</h1>";
    //add above string as PDF file content
    using var PDF = converter.RenderHtmlAsPdf(html);
    //HTML string for WaterMark
    string WMStr = "<h1 style='color:red'>WaterMark</h1>";
    //add WaterMark
    PDF.WatermarkPage(WMStr, 0, PdfDocument.WaterMarkLocation.MiddleCenter, 100, -45, "");
    //save the document
    PDF.SaveAs("E:/Sample.pdf");
}
'''
'''Watermark PDF
'''anchor-watermark-with-ironpdf
'''*
Imports IronPdf
Shared Sub Main(ByVal args() As String)
	'create rendering converter
	Dim converter = New ChromePdfRenderer()
	'source html string
	Dim html As String = "<h1 style='text-align:center'>WaterMark Example</h1>"
	'add above string as PDF file content
	Dim PDF = converter.RenderHtmlAsPdf(html)
	'HTML string for WaterMark
	Dim WMStr As String = "<h1 style='color:red'>WaterMark</h1>"
	'add WaterMark
	PDF.WatermarkPage(WMStr, 0, PdfDocument.WaterMarkLocation.MiddleCenter, 100, -45, "")
	'save the document
	PDF.SaveAs("E:/Sample.pdf")
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードによって新しく生成されたSample.pdfファイルです。

Iron4 related to 6.1. IronPDFによるウォーターマーク

任意の種類のウォーターマークを追加し、そのプロパティをCSSで設定することができます。 では、次にActivePDF WebGrabberを使用して同じタスクを行います。

6.2. ActivePDFによるウォーターマーク

ActivePDF WebGrabberには、IronPDFとは異なり、ウォーターマーク用の特定の機能が用意されていません。 しかし、この目的のための回避策としてAddStampText()関数を使用できます。

AddStampText(float x, float y, string stampText);

  • 新しいTextStampの原点のx座標を設定するためのfloat x
  • float y は、新しいテキストスタンプの原点の y 座標を設定します。
  • stampTextはTextStampの実際のテキストです。

    注意: ActivePDF WebGrabberは、TextStampに対するCSSスタイリングをサポートしていません。他の提供された機能を使用して設定する必要があります。

using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //HTML source for Page content
    string html = "<h1 style='text-align:center'>WaterMark Example</h1>";
    //assign page content source
    wg.CreateFromHTMLText = html;
    //add text stamp as WaterMark
    wg.AddStampText(270.0f, 350.0f, "WaterMark");
    //specify WaterMark's font size
    wg.StampFontSize = 20;
    //specify WaterMark's font family
    wg.StampFont = "Times New Roman";
    //specify WaterMark's opacity
    wg.StampFontTransparency = 1f;
    //specify WaterMark's rotation
    wg.StampRotation = 45.0f;
    //specify WaterMark's color
    wg.StampColorNET = new ADK.PDF.Color() { Red = 255, Green = 0, Blue = 0, Gray = 0 };
    //specify directory for newly created file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert above sources to PDF file
    wg.ConvertToPDF();
}
using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //HTML source for Page content
    string html = "<h1 style='text-align:center'>WaterMark Example</h1>";
    //assign page content source
    wg.CreateFromHTMLText = html;
    //add text stamp as WaterMark
    wg.AddStampText(270.0f, 350.0f, "WaterMark");
    //specify WaterMark's font size
    wg.StampFontSize = 20;
    //specify WaterMark's font family
    wg.StampFont = "Times New Roman";
    //specify WaterMark's opacity
    wg.StampFontTransparency = 1f;
    //specify WaterMark's rotation
    wg.StampRotation = 45.0f;
    //specify WaterMark's color
    wg.StampColorNET = new ADK.PDF.Color() { Red = 255, Green = 0, Blue = 0, Gray = 0 };
    //specify directory for newly created file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert above sources to PDF file
    wg.ConvertToPDF();
}
Imports APWebGrabber
Shared Sub Main(ByVal args() As String)
	'Instantiate Object
	Dim wg As New WebGrabber()
	'HTML source for Page content
	Dim html As String = "<h1 style='text-align:center'>WaterMark Example</h1>"
	'assign page content source
	wg.CreateFromHTMLText = html
	'add text stamp as WaterMark
	wg.AddStampText(270.0F, 350.0F, "WaterMark")
	'specify WaterMark's font size
	wg.StampFontSize = 20
	'specify WaterMark's font family
	wg.StampFont = "Times New Roman"
	'specify WaterMark's opacity
	wg.StampFontTransparency = 1F
	'specify WaterMark's rotation
	wg.StampRotation = 45.0F
	'specify WaterMark's color
	wg.StampColorNET = New ADK.PDF.Color() With {
		.Red = 255,
		.Green = 0,
		.Blue = 0,
		.Gray = 0
	}
	'specify directory for newly created file
	wg.OutputDirectory = "E:/"
	'specify file name
	wg.NewDocumentName = "Sample.pdf"
	'convert above sources to PDF file
	wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

次のスクリーンショットは、新たに生成されたSample.pdfファイルのものです。

Active4 related to 6.2. ActivePDFによるウォーターマーク

6.3. IronPDFとActivePDFの違い

  • IronPDFは、ウォーターマークを追加するのを非常に簡単にします。
  • IronPDFはウォーターマークのプロパティを設定するための直接的な機能を提供します。
  • ActivePDF WebGrabberは、回避するために多くのコード行が必要な複雑なプログラミング構造を持っています。

PDFページにマージンを設定する

ローカルディスクEにあるmyHtmlFile.htmlという名前のシンプルなウェブページがあり、幅が100%で、の色の境界線があるとします。 これからPDFファイルを生成し、ページの余白を設定します。 IronPDFから始めましょう。

7.1. IronPDFでの余白設定

マージンを設定するには、IronPDF は ChromePdfRenderOptions クラスを提供し、次のプロパティがあります:

  • MarginLeft は、ページの左側からの余白を設定します。
  • MarginRight はページの右側からのマージンを設定します。
  • MarginTop はページ上部からの余白を設定します。
  • MarginBottom はページの下部から余白を設定するためのプロパティです。

    注: デフォルトで、IronPDFはページを読みやすくするために、左、上、右、下から20mmの余白を設定します。 必要ない場合は、0mmに設定できます。

/**
Set Margins
anchor-margins-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create html to PDF converter
    var converter = new ChromePdfRenderer();
    //specify left Margin
    converter.RenderingOptions.MarginLeft = 50;
    //specify top Margin
    converter.RenderingOptions.MarginTop = 40;
    //render html file to PDF
    using var PDF = converter.RenderHTMLFileAsPdf("E:/myHtmlFile.html");
    //save to the target location
    PDF.SaveAs("E:/Sample.pdf");
}
/**
Set Margins
anchor-margins-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create html to PDF converter
    var converter = new ChromePdfRenderer();
    //specify left Margin
    converter.RenderingOptions.MarginLeft = 50;
    //specify top Margin
    converter.RenderingOptions.MarginTop = 40;
    //render html file to PDF
    using var PDF = converter.RenderHTMLFileAsPdf("E:/myHtmlFile.html");
    //save to the target location
    PDF.SaveAs("E:/Sample.pdf");
}
'''
'''Set Margins
'''anchor-margins-with-ironpdf
'''*
Imports IronPdf
Shared Sub Main(ByVal args() As String)
	'create html to PDF converter
	Dim converter = New ChromePdfRenderer()
	'specify left Margin
	converter.RenderingOptions.MarginLeft = 50
	'specify top Margin
	converter.RenderingOptions.MarginTop = 40
	'render html file to PDF
	Dim PDF = converter.RenderHTMLFileAsPdf("E:/myHtmlFile.html")
	'save to the target location
	PDF.SaveAs("E:/Sample.pdf")
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードによって新しく生成されたSample.pdfファイルです。

Iron5 related to 7.1. IronPDFでの余白設定

PDFページは左側から50mm、上から40あり、左側のマージンはデフォルトで``20mmです。 私たちは、IronPDF の ChromePdfRenderOptions クラスを使用して、任意の側のマージンを設定するのがいかに簡単かを見ることができます。

マージンやその他のPDFファイルのプロパティを扱う方法の詳細については、PDF生成設定をご覧ください。

では、ActivePDF WebGrabber を使用してページの余白を設定します。

7.2. ActivePDF とのマージン

ページ余白を設定するために、ActivePDF WebGrabber は SetMargins() 関数を提供しており、次のように使用できます。

SetMargins(上余白, 下余白, 左余白, 右余白)

この関数を使用してページの余白を設定します:

using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber()
    //specify source HTML file path
    wg.URL = "E:/myHtmlFile.html";
    //Margins
    wg.SetMargins(1, 0, 1.5f, 0);
    //specify directory for newly created file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert HTML file to PDF
    wg.ConvertToPDF();
}
using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber()
    //specify source HTML file path
    wg.URL = "E:/myHtmlFile.html";
    //Margins
    wg.SetMargins(1, 0, 1.5f, 0);
    //specify directory for newly created file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert HTML file to PDF
    wg.ConvertToPDF();
}
Imports APWebGrabber
Shared Sub Main(ByVal args() As String)
	'Instantiate Object
'INSTANT VB WARNING: An assignment within expression was extracted from the following statement:
'ORIGINAL LINE: WebGrabber wg = new WebGrabber() wg.URL = "E:/myHtmlFile.html";
	New WebGrabber() wg.URL = "E:/myHtmlFile.html"
	Dim wg As New WebGrabber() wg.URL
	'Margins
	wg.SetMargins(1, 0, 1.5F, 0)
	'specify directory for newly created file
	wg.OutputDirectory = "E:/"
	'specify file name
	wg.NewDocumentName = "Sample.pdf"
	'convert HTML file to PDF
	wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードによって新しく生成されたSample.pdfファイルです。

Active5 related to 7.2. ActivePDF とのマージン

PDFページは左側から1.5f、上から1fのマージンがあることがわかります。これらのコンポーネントを使用することで、必要に応じてページのマージンを簡単に設定できます。

ActivePDFで余白を設定する方法についてさらに読む。


8. PDF にヘッダーとフッターを設定する

この比較では、PDFファイルのヘッダーとフッターの設定方法を見ていきます。提供されている関数と技法を使用して、PDFページ上にカスタムヘッダーとフッターをプログラム的に印刷する方法を説明します。

8.1. IronPDFによるヘッダーとフッター

IronPDFはヘッダーおよびフッターを設定するために使用できる以下のプロパティを提供します:

  • LeftText : 左側にヘッダーまたはフッターのテキストを設定します。
  • CenterText : ヘッダーまたはフッターのテキストを中央に印刷します。
  • RightText: 左側にヘッダーまたはフッターのテキストを設定します。
  • FontFamily : ヘッダーまたはフッターのテキストのフォントファミリーを設定します。
  • FontSize : ヘッダーまたはフッターテキストのフォントサイズを設定します。
  • スペーシング : ページの内容とヘッダーまたはフッターの間のスペースを設定します。
  • DrawDividerLine: ページの内容をヘッダーまたはフッターから分離する水平線を描画します。

    ヘッダーまたはフッターのために、IronPDFの以下の定義済関数を中括弧{}内で使用できます:

  • {page} は現在のページ番号を印刷します。
  • {total-pages} はPDFの総ページ数を印刷するために使用されます。
  • {url} は、レンダリングされたPDFのURLを印刷するために使用されます。
  • {date} は今日の日付を印刷するために使用されます。
  • {time} 現在の時刻を印刷します。
  • {html-title} は、レンダリングされたHTMLファイルのタイトルを印刷するために使用されます。
  • {pdf-title} はドキュメントのタイトルを設定します。

    以下の例を見てみましょう。上記の機能を使用してページのヘッダーとフッターを設定します。

/**
Set Header Footers
anchor-headers-and-footers-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create html to PDF converter
    var converter = new IronPdf.ChromePdfRenderer();
    //Page Content source
    string html = "<h1 style='text-align:center;'>Page Content</h2>";
    //Assign source to converter
    using var PDF = converter.RenderHtmlAsPdf(html);
    //Add Header settings
    converter.RenderingOptions.TextHeader = new TextHeaderFooter()
    {
        LeftText = "Header Text",
        RightText = "{date} {time}",
        DrawDividerLine=true,
        FontSize=13
    };
    //Add Footer settings
    converter.RenderingOptions.TextFooter = new TextHeaderFooter()
    {
        RightText = "Page {page} of {total-pages}",
        FontSize = 12
    };
    //save to target location
    PDF.SaveAs("E:/Sample.pdf");
}
/**
Set Header Footers
anchor-headers-and-footers-with-ironpdf
**/
using IronPdf;
static void Main(string [] args)
{
    //create html to PDF converter
    var converter = new IronPdf.ChromePdfRenderer();
    //Page Content source
    string html = "<h1 style='text-align:center;'>Page Content</h2>";
    //Assign source to converter
    using var PDF = converter.RenderHtmlAsPdf(html);
    //Add Header settings
    converter.RenderingOptions.TextHeader = new TextHeaderFooter()
    {
        LeftText = "Header Text",
        RightText = "{date} {time}",
        DrawDividerLine=true,
        FontSize=13
    };
    //Add Footer settings
    converter.RenderingOptions.TextFooter = new TextHeaderFooter()
    {
        RightText = "Page {page} of {total-pages}",
        FontSize = 12
    };
    //save to target location
    PDF.SaveAs("E:/Sample.pdf");
}
'''
'''Set Header Footers
'''anchor-headers-and-footers-with-ironpdf
'''*
Imports IronPdf
Shared Sub Main(ByVal args() As String)
	'create html to PDF converter
	Dim converter = New IronPdf.ChromePdfRenderer()
	'Page Content source
	Dim html As String = "<h1 style='text-align:center;'>Page Content</h2>"
	'Assign source to converter
	Dim PDF = converter.RenderHtmlAsPdf(html)
	'Add Header settings
	converter.RenderingOptions.TextHeader = New TextHeaderFooter() With {
		.LeftText = "Header Text",
		.RightText = "{date} {time}",
		.DrawDividerLine=True,
		.FontSize=13
	}
	'Add Footer settings
	converter.RenderingOptions.TextFooter = New TextHeaderFooter() With {
		.RightText = "Page {page} of {total-pages}",
		.FontSize = 12
	}
	'save to target location
	PDF.SaveAs("E:/Sample.pdf")
End Sub
$vbLabelText   $csharpLabel

以下のスクリーンショットは、上記のコードによって新しく生成されたSample.pdfファイルです。

Iron6 related to 8.1. IronPDFによるヘッダーとフッター

私たちはそれを確認できます

  • ヘッダーテキスト はヘッダーの左側に印刷されます。
  • DateTime はヘッダーの右側に印刷されます。
  • ヘッダーとページの内容を分ける水平線が引かれています。
  • フッターの右側に、TotalPages の CurrentPage ページ

    IronPDFを使用してHTMLからPDFへのプロパティ設定についてさらに読む。

    それでは、ActivePDF WebGrabberを使ってページのヘッダーとフッターを設定してみましょう:

8.2. ActivePDFを使用したヘッダーとフッター

ActivePDF WebGrabber は、ヘッダーとフッターをそれぞれ設定するために HeaderHTML および FooterHTML プロパティを提供します。 生のHTMLはこれらのプロパティに、ページヘッダーやフッターとして渡されます。 IronPDFとは異なり、ActivePDF WebGrabberにはヘッダーおよびフッターの配置を設定するための事前定義された関数が提供されていません。そのため、次のHTMLとCSSプロパティを使用して設定する必要があります:

using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //Page content source
    string html = @"<h1 style='text-align:center;'>Page Content</h2>";
    //assign above source to WebGrabber
    wg.CreateFromHTMLText = html;
    //specify Footer height
    wg.FooterHeight = 0.5f;
    //Add Footer setting
    wg.FooterHTML = "<div style='text-align: right;'>%cp% of %tp%</div>";
    //create object for datetime
    DateTime now = DateTime.Now;
    //specify header height
    wg.HeaderHeight = 0.5f;
    //Add Header setting
    wg.HeaderHTML = "<div style='float: left;'>Header Text</div>";
    //append Header settings
    wg.HeaderHTML = $"<div style='float: right;'>{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}</div>";
    //specify directory for newly created file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert above sources to PDF file
    wg.ConvertToPDF();
}
using APWebGrabber;
static void Main(string [] args)
{
    //Instantiate Object
    WebGrabber wg = new WebGrabber();
    //Page content source
    string html = @"<h1 style='text-align:center;'>Page Content</h2>";
    //assign above source to WebGrabber
    wg.CreateFromHTMLText = html;
    //specify Footer height
    wg.FooterHeight = 0.5f;
    //Add Footer setting
    wg.FooterHTML = "<div style='text-align: right;'>%cp% of %tp%</div>";
    //create object for datetime
    DateTime now = DateTime.Now;
    //specify header height
    wg.HeaderHeight = 0.5f;
    //Add Header setting
    wg.HeaderHTML = "<div style='float: left;'>Header Text</div>";
    //append Header settings
    wg.HeaderHTML = $"<div style='float: right;'>{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}</div>";
    //specify directory for newly created file
    wg.OutputDirectory = "E:/";
    //specify file name
    wg.NewDocumentName = "Sample.pdf";
    //convert above sources to PDF file
    wg.ConvertToPDF();
}
Imports APWebGrabber
Shared Sub Main(ByVal args() As String)
	'Instantiate Object
	Dim wg As New WebGrabber()
	'Page content source
	Dim html As String = "<h1 style='text-align:center;'>Page Content</h2>"
	'assign above source to WebGrabber
	wg.CreateFromHTMLText = html
	'specify Footer height
	wg.FooterHeight = 0.5F
	'Add Footer setting
	wg.FooterHTML = "<div style='text-align: right;'>%cp% of %tp%</div>"
	'create object for datetime
	Dim now As DateTime = DateTime.Now
	'specify header height
	wg.HeaderHeight = 0.5F
	'Add Header setting
	wg.HeaderHTML = "<div style='float: left;'>Header Text</div>"
	'append Header settings
	wg.HeaderHTML = $"<div style='float: right;'>{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}</div>"
	'specify directory for newly created file
	wg.OutputDirectory = "E:/"
	'specify file name
	wg.NewDocumentName = "Sample.pdf"
	'convert above sources to PDF file
	wg.ConvertToPDF()
End Sub
$vbLabelText   $csharpLabel

次のスクリーンショットは、上記のコードから新たに生成されたSample.pdfファイルのものです。

Active6 related to 8.2. ActivePDFを使用したヘッダーとフッター

ActivePDF WebGrabberでヘッダーとフッターを設定する方法についてさらに読む

8.3. IronPDF と ActivePDF の違い

  • ActivePDF WebGrabberには、ヘッダーをページコンテンツから区切る水平線を描くためのあらかじめ定義された機能がありません。
  • ActivePDFは、.NETフレームワークのDateTime関数の使用を必要とします。
  • IronPDFはヘッダーとフッターのプロパティを簡単に設定できます。

9. ActivePDFコンポーネント一覧

Name Detail
ActivePDF DocConverter It is used to convert popular file types to and from PDF format.
ActivePDF WebGrabber It grabs the HTML from many sources and converts it to PDF files.
ActivePDF DocSpace It provides Batch Process Automation, and a user interface for display, generate, converting, manipulating, and interacting with PDF and other file formats.
ActivePDF Toolkit It is used to create, modify, view, extract, manipulate, and automate the document content to and from PDF files.
ActivePDF Portal It enables the users to view and modify PDF documents from any source in a standard web browser.
ActivePDF CADConverter It is used to convert CAD files into PDF.
ActivePDF Xtractor It is used to extract and find the text and images from PDF files.
ActivePDF Spooler It allows the developer to print the PDF file page on paper.
ActivePDF Redactor It is used to hide sensitive information from the viewer.
ActivePDF Server It provides the printing solution for different purposes.

ライセンス

ActivePDFは、ActivePDFウェブサイトにパッケージに関する情報を提供していません。 ライセンスに関する情報を得るには、営業担当者に連絡する必要があります。 ただし、どのタイプのプロダクションライセンスを探しているのか、正確に把握しておく必要があります。 彼らは価格のリストを提供していませんが、価格は年間ライセンスで $1,180 から始まり、使用範囲によってはそれ以上になることがあり、見積もりを取得するためには詳細を明記する必要があります。

IronPDFは、ライセンスを$749 から提供し、多くのカスタマイズ可能なオプションを備えた透明な価格設定を行っています。 ご質問がございましたら、チームにお問い合わせください。


チュートリアル クイック アクセス

IronPDF APIリファレンスを探索する

IronPDF C# ライブラリのAPIリファレンスを探索し、IronPDFのすべての機能、クラス、メソッドフィールド、名前空間、および列挙型の詳細を確認してください。

APIリファレンスを表示
Documentation related to チュートリアル クイック アクセス
チペゴ
ソフトウェアエンジニア
チペゴは優れた傾聴能力を持ち、それが顧客の問題を理解し、賢明な解決策を提供する助けとなっています。彼は情報技術の学士号を取得後、2023年にIron Softwareチームに加わりました。現在、彼はIronPDFとIronOCRの2つの製品に注力していますが、顧客をサポートする新しい方法を見つけるにつれて、他の製品に関する知識も日々成長しています。Iron Softwareでの協力的な生活を楽しんでおり、さまざまな経験を持つチームメンバーが集まり、効果的で革新的な解決策を提供することに貢献しています。チペゴがデスクを離れているときは、良い本を楽しんだり、サッカーをしていることが多いです。
< 以前
Aspose PDFコンバーターチュートリアルと比較
次へ >
スパイアPDF C# HTMLからPDFへのチュートリアル&ライブラリ比較