フッターコンテンツにスキップ
ビデオ

C#でPDFをエクスポートする方法 | IronPDF

Sumatra PDFからIronPDFへの移行は、PDFワークフローをデスクトップビューアアプリケーションによる外部プロセス管理から、完全なPDF作成、操作、抽出機能を備えた.NETネイティブライブラリ統合へと変えます。 このガイドは、Sumatra PDFの外部依存関係、AGPLv3コピーレフトの義務、および開発ライブラリではなくビューア/プリンタであるという基本的な制限を排除する、完全なステップバイステップの移行パスを提供します。

なぜスマトラPDFからIronPDFへ移行するのか

スマトラを理解する PDF

Sumatra PDFは、そのシンプルさと速度で有名な軽量でオープンソースのWindows用PDFリーダー/プリンターです。 また、EPUB、MOBI、CBZ/CBR、FB2、CHM、XPS、およびDjVuファイルも表示します。 しかし、Sumatra PDF は、PDF ファイルの表示と印刷以外の作成や操作に必要な機能を提供せず、公式の .NET SDK や NuGet パッケージもありません — コミュニティのラッパーは単に SumatraPDF.exe を実行するだけです。

Sumatra PDFは、スタンドアロンのWindowsデスクトップビューア/プリンターアプリケーションであり、開発ライブラリではありません。 .NETアプリケーションでSumatra PDFを使用している場合、おそらく次のようなことが考えられます:

  1. 外部プロセスとして SumatraPDF.exe を起動して PDF を表示
  2. コマンドラインを使用して PDF を印刷 (-print-to "<printer>") 3.ユーザーがインストールしなければならない依存関係として、このツールに依存してください。

スマトラPDF統合の主な問題点

課題 インパクト
ライブラリではありません プログラムによるPDFの作成や編集はできません。
外部プロセスの場合 SumatraPDF.exe を開始する必要があります; プロセス内のAPIはありません
AGPLv3ライセンス 強力なコピーレフト(いくつかのファイルはBSDライセンス); bundling into closed-source products imposes obligations most commercial vendors avoid
ユーザー依存性 ユーザーまたはインストーラーがSumatraPDF.exeをディスクに配置する必要があります
CLIのみ 文書化されたコマンドライン引数に限定
表示/印刷のみ PDFの作成、編集、操作はできません。
Windowsのみ LinuxまたはmacOSビルドはありません

スマトラPDFとIronPDFの比較

フィーチャー スマトラPDF IronPDF
タイプ アプリケーション ライブラリ
PDFリーディング はい はい
PDFの作成 なし はい
PDFの編集 なし はい
統合 制限付き(スタンドアロン) アプリケーションへの完全統合
ライセンス AGPLv3(いくつかのファイルはBSD) 商用
PDFを作成する なし はい
PDFを編集する なし はい
HTMLからPDFへ なし はい
マージ/スプリット なし はい
ウォーターマーク なし はい
デジタル署名 なし はい
フォーム入力 なし はい
テキスト抽出 なし はい
.NETインテグレーション None ネイティブ
ウェブアプリケーション なし はい

IronPDFはSumatra PDFとは異なり、特定のデスクトップアプリケーションや外部プロセスに縛られることはありません。 C#で直接PDF文書を動的に作成、編集、操作するための柔軟なライブラリを開発者に提供します。 このように外部プロセスから切り離すことで、単純明快で適応性が高く、単に見るだけでなく幅広い用途に適しているという顕著な利点があります。

現代 for .NETを対象とするチームのために、IronPDFはSumatra PDFの外部プロセスオーバーヘッドとAGPLv3コピーレフト義務を排除するネイティブライブラリ統合を提供します。


始める前に

前提条件

  1. .NET環境: .NET Framework 4.6.2+ または.NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGetアクセス: NuGetパッケージをインストールする機能
  3. IronPDFライセンス: IronPDFからライセンスキーを取得します。

インストール

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

ライセンス構成

// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

完全な API リファレンス

名前空間の変更

// Before:スマトラPDF(external process)
using System.Diagnostics;
using System.IO;

// After: IronPDF
using IronPdf;
// Before:スマトラPDF(external process)
using System.Diagnostics;
using System.IO;

// After: IronPDF
using IronPdf;
Imports System.Diagnostics
Imports System.IO

Imports IronPdf
$vbLabelText   $csharpLabel

コア機能のマッピング

スマトラPDFアプローチ IronPDF 同等物 ノート
Process.Start("SumatraPDF.exe", pdfPath) PdfDocument.FromFile() PDFを読み込む
コマンドライン引数 ネイティブAPIメソッド CLI不要
外部 pdftotext.exe pdf.ExtractAllText() テキスト抽出
外部 wkhtmltopdf.exe renderer.RenderHtmlAsPdf() HTMLからPDFへ
-print-to-default 引数 pdf.Print() 印刷
不可 PdfDocument.Merge() PDFのマージ
不可 pdf.ApplyWatermark() 透かし
不可 pdf.SecuritySettings パスワード保護

コード移行の例

例1: HTMLからPDFへの変換

ビフォア(スマトラPDF):

//スマトラPDFis a standaloneウィンドウズapp (AGPLv3) — there is NO official NuGet package.
// Download SumatraPDF.exe from https://www.sumatrapdfreader.org/and shell out to it.
// Sumatra is a viewer/printer only; it cannot convert HTML to PDF, so you must use a
// separate HTML-to-PDF tool (e.g. wkhtmltopdf) and then view/print with Sumatra.
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
        //スマトラPDFcannot directly convert HTML to PDF
        // You'd need to use wkhtmltopdf or similar, then view in Sumatra
        string htmlFile = "input.html";
        string pdfFile = "output.pdf";

        // Using wkhtmltopdf as intermediary
        ProcessStartInfo psi = new ProcessStartInfo
        {
            FileName = "wkhtmltopdf.exe",
            Arguments = $"{htmlFile} {pdfFile}",
            UseShellExecute = false
        };
        Process.Start(psi)?.WaitForExit();

        // Then open with Sumatra
        Process.Start("SumatraPDF.exe", pdfFile);
    }
}
//スマトラPDFis a standaloneウィンドウズapp (AGPLv3) — there is NO official NuGet package.
// Download SumatraPDF.exe from https://www.sumatrapdfreader.org/and shell out to it.
// Sumatra is a viewer/printer only; it cannot convert HTML to PDF, so you must use a
// separate HTML-to-PDF tool (e.g. wkhtmltopdf) and then view/print with Sumatra.
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
        //スマトラPDFcannot directly convert HTML to PDF
        // You'd need to use wkhtmltopdf or similar, then view in Sumatra
        string htmlFile = "input.html";
        string pdfFile = "output.pdf";

        // Using wkhtmltopdf as intermediary
        ProcessStartInfo psi = new ProcessStartInfo
        {
            FileName = "wkhtmltopdf.exe",
            Arguments = $"{htmlFile} {pdfFile}",
            UseShellExecute = false
        };
        Process.Start(psi)?.WaitForExit();

        // Then open with Sumatra
        Process.Start("SumatraPDF.exe", pdfFile);
    }
}
Imports System.Diagnostics
Imports System.IO

Module Program
    Sub Main()
        'スマトラPDFcannot directly convert HTML to PDF
        ' You'd need to use wkhtmltopdf or similar, then view in Sumatra
        Dim htmlFile As String = "input.html"
        Dim pdfFile As String = "output.pdf"

        ' Using wkhtmltopdf as intermediary
        Dim psi As New ProcessStartInfo With {
            .FileName = "wkhtmltopdf.exe",
            .Arguments = $"{htmlFile} {pdfFile}",
            .UseShellExecute = False
        }
        Process.Start(psi)?.WaitForExit()

        ' Then open with Sumatra
        Process.Start("SumatraPDF.exe", pdfFile)
    End Sub
End Module
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string htmlContent = "<h1>Hello World</h1><p>This isHTMLからPDFへconversion.</p>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created successfully!");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string htmlContent = "<h1>Hello World</h1><p>This isHTMLからPDFへconversion.</p>";

        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");

        Console.WriteLine("PDF created successfully!");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()

        Dim htmlContent As String = "<h1>Hello World</h1><p>This is HTMLからPDFへ conversion.</p>"

        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")

        Console.WriteLine("PDF created successfully!")
    End Sub
End Class
$vbLabelText   $csharpLabel

この例は、基本的なアーキテクチャの違いを示しています。 スマトラPDFは、HTMLを直接PDFに変換することはできませんので、wkhtmltopdfのような外部ツールを仲介として使用し、結果を表示するために別のプロセスとしてスマトラを起動する必要があります。 このため、2つの外部実行ファイルと複数のプロセス起動が必要です。

IronPDF は、わずか3行のコードで ChromePdfRendererRenderHtmlAsPdf() を使用します。 外部ツール、プロセス管理、中間ファイルは使用しません。 PDF は直接メモリ上に作成され、SaveAs() で保存されます。 包括的な例については、HTML to PDF documentationを参照してください。

例 2:PDFを開いて表示する

ビフォア(スマトラPDF):

//スマトラPDFis a standaloneウィンドウズapp (AGPLv3) — no official NuGet package.
// Download SumatraPDF.exe from https://www.sumatrapdfreader.org/and call it via Process.Start.
// Useful CLI flags: -page <n>, -print-to-default, -print-to "<printer>", -print-settings, -silent.
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
        string pdfPath = "document.pdf";

        //スマトラPDFexcels at viewing PDFs
        ProcessStartInfo startInfo = new ProcessStartInfo
        {
            FileName = "SumatraPDF.exe",
            Arguments = $"\"{pdfPath}\"",
            UseShellExecute = true
        };

        Process.Start(startInfo);

        // Optional: Open specific page
        // Arguments = $"-page 5 \"{pdfPath}\""
    }
}
//スマトラPDFis a standaloneウィンドウズapp (AGPLv3) — no official NuGet package.
// Download SumatraPDF.exe from https://www.sumatrapdfreader.org/and call it via Process.Start.
// Useful CLI flags: -page <n>, -print-to-default, -print-to "<printer>", -print-settings, -silent.
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
        string pdfPath = "document.pdf";

        //スマトラPDFexcels at viewing PDFs
        ProcessStartInfo startInfo = new ProcessStartInfo
        {
            FileName = "SumatraPDF.exe",
            Arguments = $"\"{pdfPath}\"",
            UseShellExecute = true
        };

        Process.Start(startInfo);

        // Optional: Open specific page
        // Arguments = $"-page 5 \"{pdfPath}\""
    }
}
Imports System.Diagnostics
Imports System.IO

Module Program
    Sub Main()
        Dim pdfPath As String = "document.pdf"

        'スマトラPDFexcels at viewing PDFs
        Dim startInfo As New ProcessStartInfo With {
            .FileName = "SumatraPDF.exe",
            .Arguments = $"""{pdfPath}""",
            .UseShellExecute = True
        }

        Process.Start(startInfo)

        ' Optional: Open specific page
        ' .Arguments = $"-page 5 ""{pdfPath}"""
    End Sub
End Module
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        // Extract information
        Console.WriteLine($"Page Count: {pdf.PageCount}");

        //IronPDFcan manipulate and save, then open with default viewer
        pdf.SaveAs("modified.pdf");

        // Open with default PDF viewer
        Process.Start(new ProcessStartInfo("modified.pdf") { UseShellExecute = true });
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        // Extract information
        Console.WriteLine($"Page Count: {pdf.PageCount}");

        //IronPDFcan manipulate and save, then open with default viewer
        pdf.SaveAs("modified.pdf");

        // Open with default PDF viewer
        Process.Start(new ProcessStartInfo("modified.pdf") { UseShellExecute = true });
    }
}
Imports IronPdf
Imports System
Imports System.Diagnostics

Class Program
    Shared Sub Main()
        Dim pdf = PdfDocument.FromFile("document.pdf")

        ' Extract information
        Console.WriteLine($"Page Count: {pdf.PageCount}")

        ' IronPDF can manipulate and save, then open with default viewer
        pdf.SaveAs("modified.pdf")

        ' Open with default PDF viewer
        Process.Start(New ProcessStartInfo("modified.pdf") With {.UseShellExecute = True})
    End Sub
End Class
$vbLabelText   $csharpLabel

Sumatra PDFはPDFの表示に優れていますが、コマンドライン引数で外部プロセスを起動することには制限があります。 プログラムでPDFコンテンツにアクセスすることはできません。

IronPDF は PdfDocument.FromFile() で PDF を読み込み、プログラムによる完全なアクセスを提供します。 プロパティを PageCount として読み取り、ドキュメントの操作を行い、変更を保存し、システムのデフォルト PDF ビューアで開くことができます。 重要な違いは、IronPDFは単なるプロセス引数ではなく、実際のAPIを提供することです。 詳しくは、チュートリアルをご覧ください。

例3: PDFからテキストを抽出する

ビフォア(スマトラPDF):

//スマトラPDFis a standaloneウィンドウズviewer (AGPLv3) — no official NuGet package
// and no programmatic text-extraction API. To extract text you must shell out to a
// separate tool such as pdftotext (Xpdf / Poppler).
using System;
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
        //スマトラPDFis a viewer, not a text extraction library
        // You'd need to use PDFBox, iTextSharp, or similar for extraction

        string pdfFile = "document.pdf";

        // This would require external tools like pdftotext
        ProcessStartInfo psi = new ProcessStartInfo
        {
            FileName = "pdftotext.exe",
            Arguments = $"{pdfFile} output.txt",
            UseShellExecute = false
        };

        Process.Start(psi)?.WaitForExit();

        string extractedText = File.ReadAllText("output.txt");
        Console.WriteLine(extractedText);
    }
}
//スマトラPDFis a standaloneウィンドウズviewer (AGPLv3) — no official NuGet package
// and no programmatic text-extraction API. To extract text you must shell out to a
// separate tool such as pdftotext (Xpdf / Poppler).
using System;
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
        //スマトラPDFis a viewer, not a text extraction library
        // You'd need to use PDFBox, iTextSharp, or similar for extraction

        string pdfFile = "document.pdf";

        // This would require external tools like pdftotext
        ProcessStartInfo psi = new ProcessStartInfo
        {
            FileName = "pdftotext.exe",
            Arguments = $"{pdfFile} output.txt",
            UseShellExecute = false
        };

        Process.Start(psi)?.WaitForExit();

        string extractedText = File.ReadAllText("output.txt");
        Console.WriteLine(extractedText);
    }
}
Imports System
Imports System.Diagnostics
Imports System.IO

Module Program
    Sub Main()
        'スマトラPDFis a viewer, not a text extraction library
        ' You'd need to use PDFBox, iTextSharp, or similar for extraction

        Dim pdfFile As String = "document.pdf"

        ' This would require external tools like pdftotext
        Dim psi As New ProcessStartInfo With {
            .FileName = "pdftotext.exe",
            .Arguments = $"{pdfFile} output.txt",
            .UseShellExecute = False
        }

        Process.Start(psi)?.WaitForExit()

        Dim extractedText As String = File.ReadAllText("output.txt")
        Console.WriteLine(extractedText)
    End Sub
End Module
$vbLabelText   $csharpLabel

翻訳後(IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        // Extract text from all pages
        string allText = pdf.ExtractAllText();
        Console.WriteLine("Extracted Text:");
        Console.WriteLine(allText);

        // Extract text from specific page
        string pageText = pdf.ExtractTextFromPage(0);
        Console.WriteLine($"\nFirst Page Text:\n{pageText}");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");

        // Extract text from all pages
        string allText = pdf.ExtractAllText();
        Console.WriteLine("Extracted Text:");
        Console.WriteLine(allText);

        // Extract text from specific page
        string pageText = pdf.ExtractTextFromPage(0);
        Console.WriteLine($"\nFirst Page Text:\n{pageText}");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim pdf = PdfDocument.FromFile("document.pdf")

        ' Extract text from all pages
        Dim allText As String = pdf.ExtractAllText()
        Console.WriteLine("Extracted Text:")
        Console.WriteLine(allText)

        ' Extract text from specific page
        Dim pageText As String = pdf.ExtractTextFromPage(0)
        Console.WriteLine(vbCrLf & "First Page Text:" & vbCrLf & pageText)
    End Sub
End Class
$vbLabelText   $csharpLabel

Sumatra PDF はビューアであり、テキスト抽出ライブラリではありません。 テキストを抽出するには、pdftotext.exe のような外部コマンドラインツールを使用し、プロセスを起動して完了を待ち、出力ファイルを読み込み、関連するすべてのファイルI/Oとクリーンアップを処理する必要があります。

IronPDF は、ドキュメント全体に対する ExtractAllText() や特定のページに対する ExtractTextFromPage(0) によってネイティブなテキスト抽出機能を提供します。 外部プロセス、一時ファイル、クリーンアップは不要です。


機能比較

フィーチャー スマトラPDF IronPDF
:作成: HTMLからPDFへ なし はい
URLからPDFへ なし はい
テキストからPDFへ なし はい
画像からPDFへ なし はい
:操作: PDFのマージ なし はい
PDFの分割 なし はい
ページの回転 なし はい
ページの削除 なし はい
ページの並び替え なし はい
コンテンツ 透かしの追加 なし はい
ヘッダー/フッターの追加 なし はい
スタンプテキスト なし はい
スタンプ画像 なし はい
安全 パスワード保護 なし はい
デジタル署名 なし はい
暗号化 なし はい
許可設定 なし はい
:抽出: テキストの抽出 なし はい
画像の抽出 なし はい
:プラットフォーム: ウィンドウズ はい はい
Linux なし はい
macOS なし はい
ウェブアプリ なし はい
Azure/AWS なし はい

移行後の新機能

IronPDFに移行した後は、Sumatra PDFでは提供できない機能を得ることができます:

HTMLからのPDF作成

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(@"
    <html>
    <head><style>body { font-family: Arial; }</style></head>
    <body>
        <h1>Invoice #12345</h1>
        <p>Thank you for your purchase.</p>
    </body>
    </html>");

pdf.SaveAs("invoice.pdf");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(@"
    <html>
    <head><style>body { font-family: Arial; }</style></head>
    <body>
        <h1>Invoice #12345</h1>
        <p>Thank you for your purchase.</p>
    </body>
    </html>");

pdf.SaveAs("invoice.pdf");
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("
    <html>
    <head><style>body { font-family: Arial; }</style></head>
    <body>
        <h1>Invoice #12345</h1>
        <p>Thank you for your purchase.</p>
    </body>
    </html>")

pdf.SaveAs("invoice.pdf")
$vbLabelText   $csharpLabel

PDFマージ

var pdf1 = PdfDocument.FromFile("chapter1.pdf");
var pdf2 = PdfDocument.FromFile("chapter2.pdf");
var pdf3 = PdfDocument.FromFile("chapter3.pdf");

var book = PdfDocument.Merge(pdf1, pdf2, pdf3);
book.SaveAs("complete_book.pdf");
var pdf1 = PdfDocument.FromFile("chapter1.pdf");
var pdf2 = PdfDocument.FromFile("chapter2.pdf");
var pdf3 = PdfDocument.FromFile("chapter3.pdf");

var book = PdfDocument.Merge(pdf1, pdf2, pdf3);
book.SaveAs("complete_book.pdf");
Dim pdf1 = PdfDocument.FromFile("chapter1.pdf")
Dim pdf2 = PdfDocument.FromFile("chapter2.pdf")
Dim pdf3 = PdfDocument.FromFile("chapter3.pdf")

Dim book = PdfDocument.Merge(pdf1, pdf2, pdf3)
book.SaveAs("complete_book.pdf")
$vbLabelText   $csharpLabel

ウォーターマーク

var pdf = PdfDocument.FromFile("document.pdf");

pdf.ApplyWatermark(@"
    <div style='
        font-size: 60pt;
        color: rgba(255, 0, 0, 0.3);
        transform: rotate(-45deg);
    '>
        CONFIDENTIAL
    </div>");

pdf.SaveAs("watermarked.pdf");
var pdf = PdfDocument.FromFile("document.pdf");

pdf.ApplyWatermark(@"
    <div style='
        font-size: 60pt;
        color: rgba(255, 0, 0, 0.3);
        transform: rotate(-45deg);
    '>
        CONFIDENTIAL
    </div>");

pdf.SaveAs("watermarked.pdf");
Dim pdf = PdfDocument.FromFile("document.pdf")

pdf.ApplyWatermark("
    <div style='
        font-size: 60pt;
        color: rgba(255, 0, 0, 0.3);
        transform: rotate(-45deg);
    '>
        CONFIDENTIAL
    </div>")

pdf.SaveAs("watermarked.pdf")
$vbLabelText   $csharpLabel

パスワード保護

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Sensitive Data</h1>");

pdf.SecuritySettings.OwnerPassword = "owner123";
pdf.SecuritySettings.UserPassword = "user456";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;

pdf.SaveAs("protected.pdf");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Sensitive Data</h1>");

pdf.SecuritySettings.OwnerPassword = "owner123";
pdf.SecuritySettings.UserPassword = "user456";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint;

pdf.SaveAs("protected.pdf");
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Sensitive Data</h1>")

pdf.SecuritySettings.OwnerPassword = "owner123"
pdf.SecuritySettings.UserPassword = "user456"
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.NoPrint

pdf.SaveAs("protected.pdf")
$vbLabelText   $csharpLabel

移行チェックリスト

移行前

  • Sumatra プロセスのすべての起動を特定する (Process.Start("SumatraPDF.exe", ...))
  • ドキュメント印刷ワークフロー (-print-to-default 引数)
  • 使用されたSumatraコマンドライン引数をメモします
  • IronPDFからIronPDFライセンスキーを取得します

コードの更新

  • IronPdf NuGet パッケージをインストールする
  • スマトラプロセスコードを削除
  • Process.Start("SumatraPDF.exe", pdfPath)PdfDocument.FromFile(pdfPath) に置き換える
  • 外部の wkhtmltopdf.exe 呼び出しを ChromePdfRenderer.RenderHtmlAsPdf() に置き換える
  • 外部の pdftotext.exe 呼び出しを pdf.ExtractAllText() に置き換える
  • -print-to-default プロセス呼び出しを pdf.Print() に置き換える
  • アプリケーションの起動時にライセンスの初期化を追加

テスティング

  • PDF生成品質をテストする
  • 印刷機能を確認する
  • すべてのターゲットプラットフォームでテスト
  • スマトラ依存が残っていないことを確認する

クリーンアップ

  • インストーラーからSumatraを削除する
  • ドキュメントの更新
  • システム要件からスマトラを削除する

ご注意Sumatra PDFおよびwkhtmltopdfは、それぞれの所有者の登録商標です。 このサイトは、Sumatra PDFプロジェクトまたはwkhtmltopdfプロジェクトと提携しておらず、推奨したり、スポンサーしたりしていません。 すべての製品名、ロゴ、およびブランドは各所有者の所有物です。 比較は情報提供のみを目的としており、執筆時点で公開されている情報を反映しています。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

アイアンサポートチーム

私たちは週5日、24時間オンラインで対応しています。
チャット
メール
電話してね