Sign PDF Programmatically in C# .NET 10: デジタル署名 Guide
C# .NET におけるデジタル署名は、X.509証明書ベースの暗号方式でPDF文書を認証し、視覚的な署名画像だけでは実現できない改ざん検知、否認防止、および長期的な有効性を提供します。 IronPDFは.NET開発者がプログラムで署名、検証、安全なPDFを簡単に作成できるようにします。基本的な証明書署名やビジュアル署名のレンダリングから、複数当事者による承認ワークフロー、タイムスタンプサーバーとの統合、eIDASやESIGN法のようなフレームワークによる規制コンプライアンスまで、すべてをカバーします。
TL;DR: クイックスタート ガイド
このチュートリアルでは、C#でX.509証明書を使ってPDF文書にプログラムで署名、検証、セキュリティ保護する方法について、単一の署名から複数の当事者による承認チェーンまで説明します。
- 対象者: 契約管理、請求書処理、コンプライアンスシステムに文書署名を組み込んでいる.NET開発者。
- 開発内容:証明書ベースのPDF署名(
.p12)、視覚的な署名オーバーレイ、複数当事者による順次ワークフロー、署名検証、改ざん検知、および権限制御によるドキュメントロック。 - Where it runs: .NET 10、.NET 8 LTS、.NET Framework 4.6.2+、.NET Standard 2.0。
- このアプローチを使用する場合:サードパーティの署名ポータルを経由せずに、プログラムで大規模にPDFに署名する必要がある場合。
- 技術的に重要な理由:暗号署名は、視覚的な署名画像では提供できない改ざん証拠、否認防止、長期的な有効性を提供します。
このチュートリアルのコード例に沿って、クイックインストールガイドをチェックし、あなたのプロジェクトにIronPDFをセットアップしてください。 わずか数行のコードで最初のPDFに署名してください:
-
IronPDF をNuGetパッケージマネージャでインストール
PM > Install-Package IronPdf -
このコード スニペットをコピーして実行します。
var signature = new IronPdf.Signing.PdfSignature("certificate.pfx", "password"); IronPdf.PdfDocument.FromFile("document.pdf").Sign(signature).SaveAs("signed.pdf"); -
実際の環境でテストするためにデプロイする
今日プロジェクトで IronPDF を使い始めましょう無料トライアル
プロジェクト全体をダウンロード
すぐに始めるには、このチュートリアルのすべてのコード例を含む完全な作業プロジェクトをダウンロードしてください。
ダウンロードには、サンプル証明書とすべての署名例を含む完全に設定された.NETプロジェクトが含まれており、ビルドして実行する準備ができています。
IronPDFを購入または30日間のトライアルにサインアップした後、アプリケーションの最初にライセンスキーを追加してください。
IronPdf.License.LicenseKey = "KEY";
IronPdf.License.LicenseKey = "KEY";
Imports IronPdf
IronPdf.License.LicenseKey = "KEY"
今日あなたのプロジェクトでIronPDFを無料トライアルで使用開始。
目次
- TL;DR:クイックスタートガイド
- デジタル署名とビジュアル署名の比較
- デジタル署名基盤をセットアップする。
- デジタル署名をプログラムで適用する
- ビジュアル署名の外観を追加する。
- マルチパーティ署名ワークフロー
- PDF署名の法規制コンプライアンス
- 構築か購入か:カスタム署名か外部サービスか
PDF文書におけるデジタル署名とビジュアル署名の違いは何ですか?
デジタル署名"と"電子署名"は同じ意味で使われることが多いのですが、文書のセキュリティに関しては、両者はまったく異なる働きをします。 デジタル署名は、文書の内容のハッシュを秘密鍵で暗号化する暗号技術を使用します。 対応する公開鍵にアクセスできる人は誰でも、文書が署名後に変更されていないことを検証できます。
一方、ビジュアル署名は、単にPDFページ上に配置された画像です。 スキャンした手書きの署名、会社のロゴ、または名前のスタイル化されたテキストバージョンである可能性があります。 視覚的な署名は、人間の読者には文書が"署名"されているように見えますが、改ざんに対する暗号的な保護はありません。
実際には、ビジネス・アプリケーションでは、多くの場合、両方の言語が必要です。 法的契約は、ドキュメントの完全性を確保するために証明書ベースのデジタル署名の暗号化保護を求めるかもしれません。また、受取人が誰がいつ署名したかを確認できるように可視署名ブロックが必要かもしれません。
次の表は、これらの署名タイプの主な違いをまとめたものです:
| 特徴 | デジタル署名 | ビジュアル署名 |
|---|---|---|
| 暗号化保護 | PKIとX.509証明書を使用して改ざん証明シールを作成します | 画像は削除または差し替え可能です。 |
| 否認禁止 | 署名者が署名を否定できないこと | 技術的な証明は不要 |
| 改ざん検出 | いかなる修正も署名を無効にします。 | 文書が変更されたかどうかを検出する方法がない |
| 法的地位 | ESIGN法やeIDASのような規制の下で認識されています。 | 署名の意図"の要件を満たす場合のみ |
| 検証 | プログラムまたはPDFリーダーで検証できます。 | 目視のみ |
| 必要な証明書 | はい。.pfx または .p12 証明書ファイルが必要です。 | いいえ、どんな画像ファイルでも構いません。 |
ほとんどのビジネスユースケースにおいて、視覚的な表現を伴うデジタル署名は、セキュリティとユーザビリティの最強の組み合わせを提供します。 暗号化レイヤーは文書の完全性を保証し、ビジュアルレイヤーは受信者に親しみやすい署名体験を提供します。
開発チームはどのようにデジタル署名基盤をセットアップできますか?
デジタル署名を実装するには、2つのことが必要です:署名用のX.509証明書と、本番環境での証明書管理の仕組みに関する知識です。 このセクションでは、各コンポーネントについて説明します。
IronPDFはPDF署名のためにどのような証明書フォーマットをサポートしていますか?
デジタル署名は、X.509 証明書に依存します。X.509 証明書には、公開鍵と秘密鍵のペア、および証明書所有者の身元情報が含まれています。 これらの資格の有効期間は通常1~3年です。 IronPDFは、標準のPKCS#12形式の証明書に対応しており、通常は.p12ファイルとして保存されます。 これらのファイルは、署名に必要なプライベートキーと検証に必要なパブリック証明書を1つのパスワード保護されたコンテナにバンドルします。
通常、企業環境では、いくつかのソースのいずれかから証明書を取得します:
DigiCert、Sectigo、GlobalSignなどの商用認証局は、主要なPDFリーダーによって自動的に信頼される証明書を発行します。
内部PKI基盤は、組織が独自の証明書を発行することを可能にしますが、受信者は発行CAを手動で信頼する必要があるかもしれません。
自己署名証明書はプロトタイピングには役立ちますが、手動で信頼されない限り、PDFリーダーで警告を表示します。
IronPDFの証明書を読み込む際は、X509KeyStorageFlags.Exportableフラグを指定する必要があります。 これにより、暗号サブシステムが署名用の秘密鍵にアクセスできるようになります。 証明書を正しく読み込む方法を説明します:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/load-certificate.cs
using System.Security.Cryptography.X509Certificates;
// Load the certificate from a PKCS#12 file (.pfx or .p12)
// The Exportable flag allows the private key to be used for signing
var certificate = new X509Certificate2(
"company-signing-cert.pfx",
"certificate-password",
X509KeyStorageFlags.Exportable
);
Imports System.Security.Cryptography.X509Certificates
' Load the certificate from a PKCS#12 file (.pfx or .p12)
' The Exportable flag allows the private key to be used for signing
Dim certificate As New X509Certificate2(
"company-signing-cert.pfx",
"certificate-password",
X509KeyStorageFlags.Exportable
)
アウトプットの例:
証明書は正常にロードされました
件名CN=テスト署名者, O=テスト組織, C=US
発行者:CN=Test Signer、O=Test Organization、C#US
有効期限2026-01-27 7:50:04 午前
有効期限2027-01-27 午前 8:00:03
拇印:41355DE5ADD66CD64B2B99FF2CF87B9C87BD412F
秘密鍵を持っています:真
本番環境では、証明書のパスワードをハードコーディングする代わりに、Azure Key Vault、AWS Secrets Manager、HashiCorp Vaultのような安全な構成システムから引き出します。 証明書ファイルは、適切なアクセス制御で保存し、決してバージョン管理にコミットしないでください。
開発者はどのようにプログラムで PDF ドキュメントに電子署名を適用できますか?
IronPDFにおける基本的な署名ワークフローは、証明書からPdfSignatureオブジェクトを作成し、それをPDFに適用することです。 このセクションでは、メタデータを追加し、署名の動作を設定するためのオプションとともに、署名プロセスについて説明します。
What does Basic Certificate Signing look like in C#?
最も単純な署名シナリオは、既存のPDFを読み込み、証明書から署名を作成し、署名された結果を保存することです。 IronPDFはすべての暗号処理を行います:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/basic-signing.cs
using IronPdf;
using IronPdf.Signing;
// Load the PDF document that needs to be signed
PdfDocument pdf = PdfDocument.FromFile("contract.pdf");
// Create a signature object using the certificate file path and password
var signature = new PdfSignature("certificate.pfx", "password");
// Apply the cryptographic signature to the document
// This embeds an invisible digital signature in the PDF structure
pdf.Sign(signature);
// Save the signed document to a new file
pdf.SaveAs("contract-signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
' Load the PDF document that needs to be signed
Dim pdf As PdfDocument = PdfDocument.FromFile("contract.pdf")
' Create a signature object using the certificate file path and password
Dim signature As New PdfSignature("certificate.pfx", "password")
' Apply the cryptographic signature to the document
' This embeds an invisible digital signature in the PDF structure
pdf.Sign(signature)
' Save the signed document to a new file
pdf.SaveAs("contract-signed.pdf")
入力
出力
これにより、目に見えないデジタル署名が埋め込まれたPDFが作成されます。 Adobe Acrobatや署名対応のPDFリーダーで開かれたとき、ドキュメントは署名が有効かどうか、および署名後にドキュメントが変更されたかどうかを示す署名検証情報を表示します。
他の変更のためにメモリにロードせずにドキュメントに署名するだけのシナリオの場合、IronPDFは簡潔な一行アプローチを提供します。
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/one-line-signing.cs
using IronPdf;
using IronPdf.Signing;
// One-line approach for signing PDFs
// Useful for batch processing where you don't need to manipulate the document
var signature = new PdfSignature("certificate.pfx", "password");
PdfDocument.FromFile("document.pdf").Sign(signature).SaveAs("document-signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
' One-line approach for signing PDFs
' Useful for batch processing where you don't need to manipulate the document
Dim signature As New PdfSignature("certificate.pfx", "password")
PdfDocument.FromFile("document.pdf").Sign(signature).SaveAs("document-signed.pdf")
これは、他の変更を加えることなく多くの文書に署名するバッチ処理に特に便利です。
監査証跡のために署名メタデータはどのように構成されるべきですか?
デジタル署名には、署名イベントのコンテキストを示すメタデータを含めることができます。 この情報は、PDFリーダーの署名パネルに表示され、文書の監査証跡に追加されます。 IronPDFはいくつかの標準的なメタデータフィールドをサポートしています:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/signature-metadata.cs
using IronPdf;
using IronPdf.Signing;
using System;
// Load the document to be signed
PdfDocument pdf = PdfDocument.FromFile("invoice.pdf");
// Create a signature with the company certificate
var signature = new PdfSignature("certificate.pfx", "password")
{
// Add metadata to create an audit trail
// This information appears in the signature panel of PDF readers
SigningReason = "Invoice Approval",
SigningLocation = "New York Office",
SigningContact = "accounts@company.com",
SignatureDate = DateTime.UtcNow
};
// Apply the signature with all metadata included
pdf.Sign(signature);
pdf.SaveAs("invoice-approved.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System
' Load the document to be signed
Dim pdf As PdfDocument = PdfDocument.FromFile("invoice.pdf")
' Create a signature with the company certificate
Dim signature As New PdfSignature("certificate.pfx", "password") With {
' Add metadata to create an audit trail
' This information appears in the signature panel of PDF readers
.SigningReason = "Invoice Approval",
.SigningLocation = "New York Office",
.SigningContact = "accounts@company.com",
.SignatureDate = DateTime.UtcNow
}
' Apply the signature with all metadata included
pdf.Sign(signature)
pdf.SaveAs("invoice-approved.pdf")
入力
出力
メタデータフィールドは、ドキュメントのワークフローにおいてさまざまな役割を果たします:
| メタデータフィールド | 目的 | 価値例 |
|---|---|---|
SigningReason |
文書が署名された理由を説明する | "契約承認"、"監査証明" |
署名位置 |
署名が行われた記録 | "ニューヨークオフィス"、"リモートホームオフィス" |
SigningContact |
お問い合わせ先 | "legal@company.com"、"+1 555 0123" |
署名日 |
署名イベントのタイムスタンプ | DateTime.UtcNow |
企業では、これらの分野が業務データと結びつくことがよくあります。 請求書承認システムでは、署名理由を発注書番号に設定するかもしれませんし、契約管理システムでは、契約IDと承認段階を含めるかもしれません。
時間の経過による署名の有効性において、タイムスタンプサーバーはどのような役割を果たしますか?
デジタル署名には、文書がいつ署名されたかを示すタイムスタンプが含まれますが、このタイムスタンプは署名するコンピュータのローカルクロックに由来します。 何年も先の検証が必要な署名や、正確な署名時刻を証明することが法的に重要な場合、外部のタイムスタンプ機関(TSA)からの信頼できるタイムスタンプは、はるかに強力な証拠を提供します。
タイムスタンプサーバーは、文書が特定の瞬間に現在の形式で存在したことを暗号的に証明します。 署名証明書が後で期限切れになったり、失効したりしても、タイムスタンプによって、署名が適用された時点で有効であったことがわかります。 IronPDFはRFC3161タイムスタンプサーバーをサポートしています:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/timestamp-server.cs
using IronPdf;
using IronPdf.Signing;
using System;
// Load the document to sign
PdfDocument pdf = PdfDocument.FromFile("agreement.pdf");
var signature = new PdfSignature("certificate.pfx", "password")
{
SigningReason = "Agreement Execution",
// Configure a trusted timestamp server (RFC 3161 compliant)
// This provides cryptographic proof of when the document was signed
TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256,
TimeStampUrl = "http://timestamp.digicert.com"
};
// Apply the signature with the trusted timestamp
pdf.Sign(signature);
pdf.SaveAs("agreement-timestamped.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System
' Load the document to sign
Dim pdf As PdfDocument = PdfDocument.FromFile("agreement.pdf")
Dim signature As New PdfSignature("certificate.pfx", "password") With {
.SigningReason = "Agreement Execution",
' Configure a trusted timestamp server (RFC 3161 compliant)
' This provides cryptographic proof of when the document was signed
.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256,
.TimeStampUrl = "http://timestamp.digicert.com"
}
' Apply the signature with the trusted timestamp
pdf.Sign(signature)
pdf.SaveAs("agreement-timestamped.pdf")
入力
出力
主要な認証局によって運営されているものを含め、いくつかの公開タイムスタンプサーバーが一般に利用可能です。 また、大規模な組織では、会社のセキュリティポリシーに従った独自の内部タイムスタンプサーバを運用している場合もあります。
ハッシュアルゴリズムの選択は、有効性を拡張するために重要です。 SHA256が現在の標準ですが、IronPDFはより厳しいセキュリティ要件のためにSHA512もサポートしています。 SHA 1のような古いアルゴリズムは、もはや暗号学的に安全とはみなされないため、避ける必要があります。
署名はいつ文書上で不可視にすべきか、可視にすべきか?
電子署名は、PDFの暗号構造内にのみ存在する不可視署名と、指定されたページにグラフィカルな表現も表示する可視署名の2つのモードで適用することができます。 その選択は、文書の目的と受信者の期待に依存します。
既存のドキュメントレイアウトを変更すべきでない状況や、可視署名がドキュメントを煩雑にするような、ヒューマンレビューが期待されない自動ドキュメント処理において、不可視署名はうまく機能します。
受信者が署名の視覚的な証拠を期待する場合、ワークフローで特定の場所に署名を配置する必要がある場合、または文書が印刷され、署名が紙に表示される必要がある場合は、可視署名が好まれます。
次のセクションでは、ビジュアル・シグネチャの実装について詳しく説明します。
電子署名されたPDFにどのようにビジュアル署名が追加されますか?
多くのビジネスプロセスは、目に見える署名ブロックを中心に発展してきたため、受信者は文書がいつ、どこで署名されたかを確認することを期待します。 IronPDFは暗号化保護を適用しながら、ページ上に目に見える署名を表示することができます。
どのように署名画像を読み込んで配置できますか?
ビジュアル署名は通常、PDFページの特定の場所に配置される画像(スキャンした手書きの署名、社印、スタイル付きテキストブロックなど)です。 IronPDFのLoadSignatureImageFromFileメソッドは、配置とレンダリングを処理します:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/visual-signature.cs
using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
// Load the document to sign
PdfDocument pdf = PdfDocument.FromFile("contract.pdf");
var signature = new PdfSignature("certificate.pfx", "password")
{
SigningReason = "Contract Approval",
SigningLocation = "Head Office"
};
// Define the position and size for the visible signature image
// Rectangle parameters: x position, y position, width, height (in points)
// Points are measured from the bottom-left corner of the page
var signatureArea = new Rectangle(150, 100, 200, 50);
// Load and attach the visual signature image
// The image will appear at the specified location on the document
signature.LoadSignatureImageFromFile(
"signature-image.png", // Path to the signature image file
0, // Page index (0 = first page)
signatureArea // Position and dimensions
);
// Apply both the cryptographic signature and visual representation
pdf.Sign(signature);
pdf.SaveAs("contract-visually-signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports IronSoftware.Drawing
' Load the document to sign
Dim pdf As PdfDocument = PdfDocument.FromFile("contract.pdf")
Dim signature As New PdfSignature("certificate.pfx", "password") With {
.SigningReason = "Contract Approval",
.SigningLocation = "Head Office"
}
' Define the position and size for the visible signature image
' Rectangle parameters: x position, y position, width, height (in points)
' Points are measured from the bottom-left corner of the page
Dim signatureArea As New Rectangle(150, 100, 200, 50)
' Load and attach the visual signature image
' The image will appear at the specified location on the document
signature.LoadSignatureImageFromFile(
"signature-image.png", ' Path to the signature image file
0, ' Page index (0 = first page)
signatureArea ' Position and dimensions
)
' Apply both the cryptographic signature and visual representation
pdf.Sign(signature)
pdf.SaveAs("contract-visually-signed.pdf")
出力
座標系は、ページの左下隅から測定したポイント(1/72インチ)を使用します。 標準的なUSレターページ(612 x 792ポイント)の場合、署名を右下に配置するには、署名サイズと適切な余白の両方を考慮する必要があります。
署名画像をさまざまなソースから読み込むための別の方法があります:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/load-signature-image.cs
using IronPdf.Signing;
using IronSoftware.Drawing;
using System.IO;
// Create signature object
var signature = new PdfSignature("certificate.pfx", "password");
var signatureArea = new Rectangle(400, 50, 150, 75);
// Method 1: Load signature image directly from a file path
signature.LoadSignatureImageFromFile("signature.png", 0, signatureArea);
// Method 2: Load from a stream (useful for database-stored images)
using (FileStream imageStream = File.OpenRead("signature.png"))
{
signature.LoadSignatureImageFromStream(imageStream, 0, signatureArea);
}
// Method 3: Load from AnyBitmap (IronSoftware's cross-platform image type)
AnyBitmap signatureBitmap = AnyBitmap.FromFile("signature.png");
using (var stream = signatureBitmap.ToStream())
{
signature.LoadSignatureImageFromStream(stream, 0, signatureArea);
}
Imports IronPdf.Signing
Imports IronSoftware.Drawing
Imports System.IO
' Create signature object
Dim signature As New PdfSignature("certificate.pfx", "password")
Dim signatureArea As New Rectangle(400, 50, 150, 75)
' Method 1: Load signature image directly from a file path
signature.LoadSignatureImageFromFile("signature.png", 0, signatureArea)
' Method 2: Load from a stream (useful for database-stored images)
Using imageStream As FileStream = File.OpenRead("signature.png")
signature.LoadSignatureImageFromStream(imageStream, 0, signatureArea)
End Using
' Method 3: Load from AnyBitmap (IronSoftware's cross-platform image type)
Dim signatureBitmap As AnyBitmap = AnyBitmap.FromFile("signature.png")
Using stream As Stream = signatureBitmap.ToStream()
signature.LoadSignatureImageFromStream(stream, 0, signatureArea)
End Using
サポートしている画像形式は、PNG、JPEG、GIF、BMP、TIFF、WebPです。透明度のあるPNGファイルは、背景が透けて見えるため、署名画像に最適です。
複数のページにまたがる署名のポジショニングはどのように機能しますか?
複数ページの文書に署名する場合、電子署名はページ数に関係なく文書全体を保護します。 1つの暗号署名がPDF内のすべてのページをカバーします:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/multi-page-signing.cs
using IronPdf;
using IronPdf.Signing;
// Load a multi-page document
PdfDocument pdf = PdfDocument.FromFile("multi-page-contract.pdf");
// Create signature - digital signatures protect the entire document
// regardless of page count
var signature = new PdfSignature("certificate.pfx", "password");
// Sign and save the document
// The signature applies to all pages in the document
pdf.Sign(signature);
pdf.SaveAs("contract-signed-last-page.pdf");
Imports IronPdf
Imports IronPdf.Signing
' Load a multi-page document
Dim pdf As PdfDocument = PdfDocument.FromFile("multi-page-contract.pdf")
' Create signature - digital signatures protect the entire document
' regardless of page count
Dim signature As New PdfSignature("certificate.pfx", "password")
' Sign and save the document
' The signature applies to all pages in the document
pdf.Sign(signature)
pdf.SaveAs("contract-signed-last-page.pdf")
入力
出力
複数ページの署名(法的契約書の各ページのイニシャルのような)の場合、開発者は暗号署名とは別にイメージスタンプを適用できます:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/initials-stamp.cs
using IronPdf;
using IronPdf.Editing;
using IronPdf.Signing;
using IronSoftware.Drawing;
// Load the document
PdfDocument pdf = PdfDocument.FromFile("agreement.pdf");
// Create an image stamp for initials that will appear on every page
var initialsStamp = new ImageStamper("initials.png")
{
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalOffset = new Length(50, MeasurementUnit.Points),
VerticalOffset = new Length(50, MeasurementUnit.Points)
};
// Apply initials stamp to all pages
pdf.ApplyStamp(initialsStamp);
// Now apply the cryptographic signature with a full signature image on the last page
var signature = new PdfSignature("certificate.pfx", "password");
var signatureArea = new Rectangle(100, 100, 200, 100);
signature.SignatureImage = new PdfSignatureImage(
"full-signature.png",
pdf.PageCount - 1, // Last page only
signatureArea
);
// Sign the entire document cryptographically
pdf.Sign(signature);
pdf.SaveAs("agreement-initialed-and-signed.pdf");
Imports IronPdf
Imports IronPdf.Editing
Imports IronPdf.Signing
Imports IronSoftware.Drawing
' Load the document
Dim pdf As PdfDocument = PdfDocument.FromFile("agreement.pdf")
' Create an image stamp for initials that will appear on every page
Dim initialsStamp As New ImageStamper("initials.png") With {
.HorizontalAlignment = HorizontalAlignment.Right,
.VerticalAlignment = VerticalAlignment.Bottom,
.HorizontalOffset = New Length(50, MeasurementUnit.Points),
.VerticalOffset = New Length(50, MeasurementUnit.Points)
}
' Apply initials stamp to all pages
pdf.ApplyStamp(initialsStamp)
' Now apply the cryptographic signature with a full signature image on the last page
Dim signature As New PdfSignature("certificate.pfx", "password")
Dim signatureArea As New Rectangle(100, 100, 200, 100)
signature.SignatureImage = New PdfSignatureImage(
"full-signature.png",
pdf.PageCount - 1, ' Last page only
signatureArea
)
' Sign the entire document cryptographically
pdf.Sign(signature)
pdf.SaveAs("agreement-initialed-and-signed.pdf")
このアプローチでは、ビジュアル要素(複数のページに表示可能)と暗号署名(文書全体を保護)を分離します。
マルチパーティ署名ワークフローはエンタープライズ アプリケーションでどのように機能しますか?
複雑なビジネスプロセスでは、複数の担当者が特定の順序で署名する必要があります。 購入注文書は部門マネージャーの承認、次に財務レビュー、次に経営陣の承認が必要かもしれません。 IronPDFはインクリメンタルセーブと署名権限によってこれらのワークフローをサポートします。
逐次署名とは何ですか。また、インクリメンタル セーブはどのようにしてそれを可能にするのですか?
PDF文書は、バージョン管理と同様に、内部で複数のリビジョンを保存することができます。 誰かが署名するたびに、その署名はその時点の文書の状態に適用されます。 後で署名した人が新しいリビジョンに署名を追加することで、各署名が独立して検証できる承認の連鎖が生まれます。
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/sequential-signing-first.cs
using IronPdf;
using IronPdf.Signing;
// Load the purchase order document
PdfDocument pdf = PdfDocument.FromFile("purchase-order.pdf");
// First signer: Department Manager approves the purchase order
var managerSignature = new PdfSignature("certificate.pfx", "password")
{
SigningReason = "Manager Approval",
SigningLocation = "Department A"
};
// Sign the document and save
// This preserves the original state while adding the signature
pdf.Sign(managerSignature);
pdf.SaveAs("po-manager-approved.pdf");
Imports IronPdf
Imports IronPdf.Signing
' Load the purchase order document
Dim pdf As PdfDocument = PdfDocument.FromFile("purchase-order.pdf")
' First signer: Department Manager approves the purchase order
Dim managerSignature As New PdfSignature("certificate.pfx", "password") With {
.SigningReason = "Manager Approval",
.SigningLocation = "Department A"
}
' Sign the document and save
' This preserves the original state while adding the signature
pdf.Sign(managerSignature)
pdf.SaveAs("po-manager-approved.pdf")
入力
出力
文書が次の承認者に移ると、その承認者は文書を読み込み、自分の署名を追加します:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/sequential-signing-second.cs
using IronPdf;
using IronPdf.Signing;
// Load the document that already has the manager's signature
PdfDocument pdf = PdfDocument.FromFile("po-manager-approved.pdf");
// Second signer: Finance department verifies budget availability
var financeSignature = new PdfSignature("certificate.pfx", "password")
{
SigningReason = "Finance Approval",
SigningLocation = "Finance Department"
};
// Add the second signature
// Both signatures remain independently verifiable
pdf.Sign(financeSignature);
pdf.SaveAs("po-finance-approved.pdf");
Imports IronPdf
Imports IronPdf.Signing
' Load the document that already has the manager's signature
Dim pdf As PdfDocument = PdfDocument.FromFile("po-manager-approved.pdf")
' Second signer: Finance department verifies budget availability
Dim financeSignature As New PdfSignature("certificate.pfx", "password") With {
.SigningReason = "Finance Approval",
.SigningLocation = "Finance Department"
}
' Add the second signature
' Both signatures remain independently verifiable
pdf.Sign(financeSignature)
pdf.SaveAs("po-finance-approved.pdf")
出力
各リビジョンは独自の署名を維持し、PDFリーダーは、誰がいつ署名したかの完全な履歴を表示することができます。
新しい署名を追加する前に、既存の署名を確認するにはどうすればよいですか?
文書に新しい署名を追加する前に、既存の署名がまだ有効であることをコードで確認する必要があります。 適切なワークフロー以外で変更された文書には無効な署名があり、改ざんやプロセス違反を示す可能性があります。
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/verify-signatures.cs
using IronPdf;
using System;
// Load a signed document
PdfDocument pdf = PdfDocument.FromFile("contract-signed.pdf");
// Verify all existing signatures in the document
// Returns true only if ALL signatures are valid and untampered
bool isValid = pdf.VerifyPdfSignatures();
Console.WriteLine($"Signatures Valid: {isValid}");
// Get signature details
var signatures = pdf.GetVerifiedSignatures();
Console.WriteLine($"Number of Signatures: {signatures.Count}");
Imports IronPdf
Imports System
' Load a signed document
Dim pdf As PdfDocument = PdfDocument.FromFile("contract-signed.pdf")
' Verify all existing signatures in the document
' Returns true only if ALL signatures are valid and untampered
Dim isValid As Boolean = pdf.VerifyPdfSignatures()
Console.WriteLine($"Signatures Valid: {isValid}")
' Get signature details
Dim signatures = pdf.GetVerifiedSignatures()
Console.WriteLine($"Number of Signatures: {signatures.Count}")
より詳細な検査については、検証済みの各署名に関する情報を取得できます:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/get-verified-signatures.cs
using IronPdf;
using System;
// Load a document with multiple signatures
PdfDocument pdf = PdfDocument.FromFile("multi-signed-document.pdf");
// Retrieve detailed information about each verified signature
var verifiedSignatures = pdf.GetVerifiedSignatures();
// Iterate through all signatures to build an audit trail
foreach (var sig in verifiedSignatures)
{
Console.WriteLine($"Signer: {sig.SignerName}");
Console.WriteLine($"Reason: {sig.SigningReason}");
Console.WriteLine($"Location: {sig.SigningLocation}");
Console.WriteLine($"Date: {sig.SigningDate}");
Console.WriteLine($"Contact: {sig.SigningContact}");
Console.WriteLine("---");
}
Imports IronPdf
Imports System
' Load a document with multiple signatures
Dim pdf As PdfDocument = PdfDocument.FromFile("multi-signed-document.pdf")
' Retrieve detailed information about each verified signature
Dim verifiedSignatures = pdf.GetVerifiedSignatures()
' Iterate through all signatures to build an audit trail
For Each sig In verifiedSignatures
Console.WriteLine($"Signer: {sig.SignerName}")
Console.WriteLine($"Reason: {sig.SigningReason}")
Console.WriteLine($"Location: {sig.SigningLocation}")
Console.WriteLine($"Date: {sig.SigningDate}")
Console.WriteLine($"Contact: {sig.SigningContact}")
Console.WriteLine("---")
Next
この情報により、監査証跡を構築し、承認チェーンを検証し、次の段階に進む前に文書に必要な署名がすべてあることを確認できます。
IronPDFはどのようにして改ざんされたドキュメントを検出するのですか?
VerifyPdfSignatures() メソッドは、ドキュメント内の署名のいずれかが無効な場合、false を返します。 これは通常、文書に署名した後にコンテンツが変更された場合、署名データ自体が破損した場合、証明書が失効した場合、または証明書が使用された時点でまだ有効でなかった場合に発生します。
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/detect-tampering.cs
using IronPdf;
using System;
// Load a signed document and verify
PdfDocument pdf = PdfDocument.FromFile("contract-signed.pdf");
// Check if all signatures are still valid
bool isValid = pdf.VerifyPdfSignatures();
if (isValid)
{
Console.WriteLine("Document has not been tampered with");
Console.WriteLine("All signatures are valid");
}
else
{
Console.WriteLine("WARNING: Document may have been tampered with!");
Console.WriteLine("One or more signatures are invalid");
}
Imports IronPdf
Imports System
' Load a signed document and verify
Dim pdf As PdfDocument = PdfDocument.FromFile("contract-signed.pdf")
' Check if all signatures are still valid
Dim isValid As Boolean = pdf.VerifyPdfSignatures()
If isValid Then
Console.WriteLine("Document has not been tampered with")
Console.WriteLine("All signatures are valid")
Else
Console.WriteLine("WARNING: Document may have been tampered with!")
Console.WriteLine("One or more signatures are invalid")
End If
署名の削除が必要なアプリケーション(再配布用の署名なしコピーを作成する場合など)向けに、IronPDFにはRemoveSignatures()メソッドが用意されています:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/remove-signatures.cs
using IronPdf;
// Load a signed document
PdfDocument pdf = PdfDocument.FromFile("signed-template.pdf");
// Remove all digital signatures from the document
// This strips signature data but does not restore previous document state
pdf.RemoveSignatures();
// Save as an unsigned version
pdf.SaveAs("unsigned-template.pdf");
Imports IronPdf
' Load a signed document
Dim pdf As PdfDocument = PdfDocument.FromFile("signed-template.pdf")
' Remove all digital signatures from the document
' This strips signature data but does not restore previous document state
pdf.RemoveSignatures()
' Save as an unsigned version
pdf.SaveAs("unsigned-template.pdf")
署名を削除しても、以前の文書の状態は回復しないことに注意してください。 この方法では、現在の文書バージョンから署名データを取り除くだけです。
PDF署名の規制コンプライアンスを支える技術的能力とは
デジタル署名の規制は管轄区域や業界によって異なりますが、証明書の検証、タイムスタンプ、署名メタデータに関する技術的ニーズは共通しています。 このセクションでは、特定の法律上の義務(資格を持つ弁護士に相談する必要があります)の解釈を試みる代わりに、コンプライアンスフレームワークが一般的に要求する技術的な機能に焦点を当てます。
デジタル署名の主な規制フレームワークは何ですか?
次の表は、一般的な規制フレームワークとその一般的な技術要件をまとめたものです:
| フレームワーク | 管轄 | 主な技術要件 |
|---|---|---|
| ESIGN法 | 米国 | 署名の意図、電子記録への同意、記録保持 |
| ウエタ | 米国 | ESIGNと同様、州内取引に適用されます。 |
| eIDAS | 欧州連合 | 3つの署名レベル(シンプル、アドバンス、クオリファイド)、クオリファイドにはQSCDが必要です。 |
| 21 CFRパート11 | 米国FDA | 電子署名は、電子記録、監査証跡にリンクされている必要があります。 |
これらのフレームワークは一般的に、デジタル署名を適切に実装すれば、手書きの署名と法的に同等であると認識します。 デジタル署名の証拠能力は、その署名が適用された時点で有効であったことを証明できるかどうかに左右されることが多く、何年、何十年にもわたって文書を保持するためには、信頼できるタイムスタンプが不可欠となります。
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/compliance-signing.cs
using IronPdf;
using IronPdf.Signing;
using System;
// Load the compliance document
PdfDocument pdf = PdfDocument.FromFile("compliance-document.pdf");
var signature = new PdfSignature("certificate.pfx", "password")
{
// Add comprehensive metadata for audit trail requirements
SigningReason = "21 CFR Part 11 Compliance Certification",
SigningLocation = "Quality Assurance Department",
SigningContact = "compliance@company.com",
SignatureDate = DateTime.UtcNow,
// Configure a trusted timestamp for regulatory compliance
// The timestamp proves when the signature was applied
TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256,
TimeStampUrl = "http://timestamp.digicert.com"
};
// Apply the signature with timestamp and full metadata
pdf.Sign(signature);
pdf.SaveAs("compliance-document-certified.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System
' Load the compliance document
Dim pdf As PdfDocument = PdfDocument.FromFile("compliance-document.pdf")
Dim signature As New PdfSignature("certificate.pfx", "password") With {
' Add comprehensive metadata for audit trail requirements
.SigningReason = "21 CFR Part 11 Compliance Certification",
.SigningLocation = "Quality Assurance Department",
.SigningContact = "compliance@company.com",
.SignatureDate = DateTime.UtcNow,
' Configure a trusted timestamp for regulatory compliance
' The timestamp proves when the signature was applied
.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256,
.TimeStampUrl = "http://timestamp.digicert.com"
}
' Apply the signature with timestamp and full metadata
pdf.Sign(signature)
pdf.SaveAs("compliance-document-certified.pdf")
入力
出力
規制業種に適用される証明書の要件は何ですか?
異なる規制の文脈では、署名に使用する証明書の基準が指定される場合があります。 これらの基準には、認定当局による発行、最小鍵長 (通常2048ビットRSAまたは同等)、特定の拡張鍵使用属性、またはHSMやスマートカードソリューションを使用したハードウェアベースの鍵ストレージが含まれることがあります。
IronPDFは標準フォーマット仕様に適合したX.509証明書で動作し、お好みの認証局の証明書を使用することができます。 ハードウェア保護されたキーを必要とする環境において、IronPDFはHsmSigner機能を通じて、PKCS#11ベースのHSM統合をサポートしています。
規制のある業界の方は、法務部門やコンプライアンス部門と連携して必要なものを明確にし、それに見合った署名インフラを構築する必要があります。
署名許可制御はどのようにドキュメント ライフサイクル管理をサポートしますか?
署名後、追加の署名者が署名を追加したり、フォームフィールドに入力できるようにするなど、特定の目的のために文書を編集可能な状態に保つ必要がある場合があります。 IronPDFのSignaturePermissions列挙型は、署名後にどのような変更が許可されるかを制御します:
:path=/static-assets/pdf/content-code-examples/tutorials/pdf-digital-signatures-csharp-guide/signature-permissions.cs
using IronPdf;
using IronPdf.Signing;
// Load a form document that needs signing
PdfDocument pdf = PdfDocument.FromFile("approval-form.pdf");
// Sign with specific permissions for document lifecycle management
// AdditionalSignaturesAndFormFillingAllowed permits form completion and additional signatures after signing
pdf.SignWithFile(
"approver-cert.pfx",
"password",
null,
SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed
);
// Save the signed document with form-filling permissions enabled
pdf.SaveAs("approval-form-signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
' Load a form document that needs signing
Dim pdf As PdfDocument = PdfDocument.FromFile("approval-form.pdf")
' Sign with specific permissions for document lifecycle management
' AdditionalSignaturesAndFormFillingAllowed permits form completion and additional signatures after signing
pdf.SignWithFile(
"approver-cert.pfx",
"password",
Nothing,
SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed
)
' Save the signed document with form-filling permissions enabled
pdf.SaveAs("approval-form-signed.pdf")
利用可能な許可レベルは以下のとおりです:
| 許可レベル | 署名後の変更 |
|---|---|
変更を許可しない。 |
文書は完全にロックされています |
FormFillingAllowed |
入力できるのはフォームフィールドのみで、内容の変更はできません。 |
AdditionalSignaturesAndFormFillingAllowed(追加署名とフォーム記入を許可する)。 |
フォーム入力と追加署名が可能 |
FormFillingAndAnnotationsAllowed |
フォーム入力と注釈が可能であること。 |
適切な許可レベルは、文書の役割によって異なります。 完了した契約書では NoChangesAllowed が使用される一方、まだ進行中の承認フォームでは、他の承認者によるフォームへの入力や追加の署名が可能になるよう AdditionalSignaturesAndFormFillingAllowed が使用される場合があります。
カスタム署名を構築することが、外部サービスを使用するよりも理にかなっているのはどのような場合ですか?
文書署名を実装する人は、基本的なアーキテクチャの決定に直面します。つまり、独自のアプリケーションに署名機能を組み込むか、ホストされた署名サービスを利用するかです。 どちらのアプローチにも適材適所があり、適切な選択は、使用量、カスタマイズの要求、コンプライアンスへの配慮、総所有コストによって決まります。
内部署名機能の構築にはどのような要因がありますか?
署名機能をアプリケーションに直接組み込むことが理にかなっているシナリオをいくつか紹介します:
文書量が多いため、規模が大きくなると、トランザクションごとの価格設定が高価になります。 毎月何千ものドキュメントを処理するビジネスでは、署名ごとのAPI料金よりもIronPDFのような永久ライセンスライブラリの方が経済的であることがよくあります。 一度のライセンス投資で、継続的なトランザクションコストに比べてすぐに元が取れます。
独自のプロセス要件は、外部の署名サービスが独自のパラダイムを持っている場合に発生します。 承認フローが特殊であったり、ドキュメントの取り扱いが特殊であったり、標準的なサービスでは対応できないような統合が必要であったりするチームでは、サービスの制限に合わせるよりも、独自のソリューションを構築する方が簡単であることがよくあります。
データ主権とセキュリティポリシー規制、セキュリティポリシー、または契約上の義務により、外部サービスにドキュメントを送信できない企業があります。 署名プロセスを社内で実行することにより、ドキュメントが社内の境界内に留まることが保証されます。
オフラインまたはエアギャップ環境は、ネットワーク接続が必要なホスト型ソリューションに依存することができません。 切断された環境(フィールドサービスアプリ、機密システム、インターネットが不安定な場所)で動作する必要があるアプリケーションには、ローカルに実装された署名機能が必要です。
コスト予測可能性は、サブスクリプションベースの価格設定が蓄積する継続的な費用を生むため重要です。 永続的なライブラリライセンスは安定したコストを提供するため、財務部門はボリュームの変動や価格の上昇を心配することなく計画を立てることができます。
どのようなシナリオでホスト型署名ソリューションが好まれますか?
ホスト型ソリューションは、さまざまな状況で効果を発揮します:
多様な署名者による少量の署名 文書に、独自の証明書を持たない社外の人の署名が必要な場合に発生します。 本人確認と証明書発行を行うサービスは、摩擦を減らします。 このようなインフラを社内で構築しても、たまに使用する程度で報われることはほとんどありません。
迅速なデプロイは、ゼロから構築する開発リソースなしで、素早くサインアップして実行する必要がある場合に重要です。 これらのプラットフォームは、簡単に使用できるユーザーインターフェイスとメール通知を備えており、即時利用可能な機能を提供します。
コンプライアンス委任は、ベンダーが特定の規制フレームワークに特化し、独自に取得するには高価な認証や証明を提供できる場合に、その価値が高まります。
サインは、投資する価値のあるコアコンピテンシーなのか、それとも専門家に任せた方が良いコモディティ機能なのか、しばしば決断を迫られます。 業務の中心的な部分として文書を扱う企業(法律事務所、金融機関、医療機関、政府機関)は、通常、署名インフラを所有することで、より良い利益を得ることができます。 文書署名が二次的なものである場合は、外注オプションのシンプルさを好むかもしれません。
開発チームはどのように署名インフラストラクチャのニーズを評価できますか?
どちらのアプローチにもコミットする前に、以下の要素を考慮してください:
現在および予測される数量が、コスト分析の原動力となります。 現在、署名が必要な文書の数はどれくらいですか?
統合の考慮事項は、アーキテクチャに影響を与えます。 署名は、既存のアプリケーションやワークフローにどのように適合しますか? ライブラリは最大限の柔軟性を提供しますが、外部プラットフォームでは、そのAPIやユーザーインターフェースに合わせる必要がある場合があります。
署名者のタイプは複雑さに影響します。 文書への署名は、管理された証明書を使用する社内ユーザーによってのみ行われるのでしょうか、それとも外部の署名者にも対応する必要があるのでしょうか。
コンプライアンスの状況が技術的な要件を決定します。 どのような規制が適用され、実装の選択にどのように影響しますか? サービスによっては、より簡単に対応できるものもあります; その他は内部統制が必要です。
技術リソースが実現可能性を決定します。 チームには、署名機能を実装し、維持するための帯域幅がありますか。
次のステップ
デジタル署名を.NETアプリケーションに組み込むことは、暗号の基礎とビジネス文書処理を推進する実用的なニーズの両方を理解することを意味します。 IronPDFは、証明書ベースの署名、ビジュアル署名レンダリング、マルチパーティワークフローのサポート、および署名検証のための技術的基礎を提供する一方で、これらの機能をいつ、どのように使用するかというアーキテクチャ上の決定は、具体的な要件を知っている開発者に任されています。
このガイドで取り上げる機能は、契約締結の自動化、承認チェーンの実装、コンプライアンス要件への対応など、堅実な署名実装のためのビルディングブロックを提供します。 ハードウェアに裏打ちされた鍵ストレージを必要とするエンタープライズ環境のために、HSM署名ガイドは、これらのパターンをPKCS#11デバイスに拡張します。 署名がより広範な文書セキュリティ戦略の一部である場合は、パスワード保護と権限やPDF暗号化と組み合わせて、重層的な防御を行います。
構築開始の準備はできましたか? IronPDFをダウンロードして、無料トライアルで試してください。 購入を決定する前に、実際の文書で証明書ベースの署名、署名検証、マルチパーティワークフローを評価することができます。 署名アーキテクチャやコンプライアンス統合について質問がある場合は、当社のエンジニアリング・サポート・チームにお問い合わせください。
よくある質問
PDFにおけるデジタル署名とは何ですか?
電子署名は、PDF文書の真正性と完全性を検証するために使用される暗号メカニズムです。文書が改ざんされていないことを保証し、署名者の身元を確認します。
C#でIronPDFを使って電子署名を実装するにはどうすればいいですか?
IronPDFはC#を使ってPDFに電子署名を実装するための簡単なAPIを提供します。証明書による署名、ビジュアル署名の追加、マルチパーティワークフローの管理など、プログラムで文書に署名することができます。
IronPDFはどのような種類の電子署名をサポートしていますか?
IronPDFは証明書ベースの署名、ビジュアル署名、追加の検証のためのタイムスタンプサーバーを必要とする署名など、様々なタイプの電子署名をサポートします。
IronPDFを使ってPDFの電子署名を検証できますか?
はい、IronPDFはPDFドキュメントのデジタル署名を検証する機能を備えており、ドキュメントが本物であり、署名後に改ざんされていないことを保証します。
デジタル署名におけるタイムスタンプサーバーの役割は何ですか?
タイムスタンプサーバーは、デジタル署名がいつ文書に適用されたかを確認するための信頼できるタイムソースを提供します。これは、署名の正確な時刻を検証することにより、セキュリティのレイヤーを追加します。
ビジュアル署名と電子証明書の違いは何ですか?
ビジュアル署名は、文書上に署名のグラフィカルな表現を表示しますが、デジタル証明書は、必ずしも視覚的なマークを表示することなく、真正性と完全性を暗号学的に証明します。
IronPDFはマルチパーティ署名ワークフローに対応できますか?
はい、IronPDFは複数当事者による署名ワークフローを管理することができ、複数の当事者が協調して安全に文書に署名することができます。
PDF文書で電子署名を使用するメリットは何ですか?
デジタル署名は、文書の完全性と真正性を保証することで、セキュリティを強化します。また、従来の方法よりも迅速で効率的な電子署名を可能にすることで、ワークフローを合理化します。
ユーザーの操作なしにプログラムでPDFに署名することは可能ですか?
IronPDFを使えば、ユーザーの操作を必要とせずにC#でプログラム的にPDFに署名することができ、自動化されたワークフローやバッチ処理に理想的です。







