C#로 PDF에 디지털 서명하기 위한 개발자 가이드
이 가이드에서는 IronPDF를 사용하여 C#에서 PDF에 디지털 서명하는 방법을 설명합니다. 인증서 기반 디지털 서명, 시각적 서명 및 대화형 서명 필드를 다룹니다.
"PDF에 서명하기"는 여러 가지를 뜻할 수 있습니다. 디지털 서명은 보안 인증서를 파일에 적용하여 이후의 변경 사항을 감지할 수 있게 합니다. 시각적 서명은 자필 서명 이미지를 페이지에 스탬프로 추가합니다. 대화형 서명 필드는 수신자가 자신의 디지털 ID로 서명할 수 있는 빈 영역을 제공합니다. IronPDF for .NET 라이브러리는 이 세 가지 방식을 모두 지원하며, X509Certificate2를 사용한 디지털 서명부터 서명 필드와 서명 검증까지 처리합니다.
다음 예제는 한 줄의 코드로 .pfx 인증서를 사용하여 기존 PDF에 서명합니다.
-
1IronPDF를 NuGet Package Manager로 설치하십시오
-
2다음 코드 조각을 복사하여 실행하세요.
IronPdf.PdfDocument.FromFile("input.pdf").SignWithFile("certificate.pfx", "password").SaveAs("signed.pdf");IronPdf.PdfDocument.FromFile("input.pdf").SignWithFile("certificate.pfx", "password").SaveAs("signed.pdf")IronPdf.PdfDocument.FromFile("input.pdf").SignWithFile("certificate.pfx", "password").SaveAs("signed.pdf") -
3실제 운영 환경에서 테스트할 수 있도록 배포하세요.
오늘 프로젝트에서 IronPDF 사용을 시작해보세요 무료 체험
기본 작업 절차(5단계)
- IronPDF for .NET 라이브러리를 설치합니다.
X509Certificate2객체를 사용하여 디지털 서명을 적용합니다.- 디지털 서명을 나타내는 이미지를 추가합니다.
- 그래픽 또는 자필 서명을 PDF에 스탬프로 추가합니다.
- 전자 서명을 위한 대화형 서명 양식 필드를 추가합니다.
인증서를 사용하여 PDF에 디지털 서명하는 방법
인증서 파일(.pfx 또는 .p12 등)로 만든 디지털 서명을 통해 서명자를 식별할 수 있으며, 문서를 읽는 사람은 누구나 서명 이후의 변경 사항을 감지할 수 있습니다.
IronPDF는 세 가지 서명 방법을 제공합니다. PdfSignature 클래스는 인증서 및 서명과 함께 기록된 메타데이터를 보관합니다.
| 서명 방법 | 설명 |
|---|---|
Sign | 직접 생성하고 구성한 PdfSignature 객체를 사용하여 PDF에 서명합니다. |
SignWithFile | 디스크에 위치한 디지털 서명 인증서 파일(.pfx 또는 .p12)을 사용하여 PDF에 서명합니다. |
SignWithStore | 컴퓨터의 인증서 저장소에서 지문 ID로 식별되는 디지털 서명을 사용하여 PDF에 서명합니다. |
X509Certificate2 객체 사용하기
서명 설정을 세부적으로 제어하려면 인증서 파일에서 X509Certificate2 객체를 생성해 PdfSignature에 전달하세요. 서명 과정에서 개인 키를 내보내므로 X509KeyStorageFlags.Exportable 플래그를 지정해 인증서를 로드하세요. 이 플래그가 없으면 서명에 실패합니다. 코드 예제 섹션에서 더 많은 디지털 서명 예제를 확인할 수 있습니다.
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Create a new PDF from an HTML string for demonstration.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>");
// Load the certificate from a .pfx file with its password.
// The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
var cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create a PdfSignature object using the loaded certificate.
var signature = new PdfSignature(cert);
// Apply the signature to the PDF document.
pdf.Sign(signature);
// Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf");using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Create a new PDF from an HTML string for demonstration.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>");
// Load the certificate from a .pfx file with its password.
// The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
var cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create a PdfSignature object using the loaded certificate.
var signature = new PdfSignature(cert);
// Apply the signature to the PDF document.
pdf.Sign(signature);
// Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf");Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
' Create a new PDF from an HTML string for demonstration.
Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>")
' Load the certificate from a .pfx file with its password.
' The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
Private cert = New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create a PdfSignature object using the loaded certificate.
Private signature = New PdfSignature(cert)
' Apply the signature to the PDF document.
pdf.Sign(signature)
' Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf")Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
' Create a new PDF from an HTML string for demonstration.
Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderHtmlAsPdf("<h1>Signed Document</h1><p>This document has been digitally signed.</p>")
' Load the certificate from a .pfx file with its password.
' The X509KeyStorageFlags.Exportable flag is crucial for allowing the private key to be used in the signing process.
Private cert = New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create a PdfSignature object using the loaded certificate.
Private signature = New PdfSignature(cert)
' Apply the signature to the PDF document.
pdf.Sign(signature)
' Save the securely signed PDF document.
pdf.SaveAs("Signed.pdf")위 코드는 먼저 간단한 PDF를 생성한 뒤 .pfx 인증서 파일을 인증서 객체로 로드합니다. 디지털 ID를 나타내는 이 객체를 서명 생성자에 전달합니다. 마지막으로 Sign 메서드로 문서에 서명을 적용한 뒤 문서를 저장합니다. 인증서 클래스에 대한 자세한 내용은 공식 Microsoft 문서를 참조하세요.
IronPDF는 RSA 및 ECDSA 인증서를 모두 지원합니다. ECDSA 인증서를 사용하는 경우, 인증서 객체 대신 .pfx 파일의 경로나 파일 바이트를 서명 생성자에 전달하세요. Windows에서 ECDSA 키를 인증서 객체에 로드하면 서명에 필요한 형식으로 키를 내보낼 수 없어 서명 시 CryptographicException이 발생합니다.
디지털 서명에 세부 정보 추가하기
디지털 서명에는 인증서 외에도 서명 위치, 서명 사유, 연락처 정보와 같은 메타데이터와 신뢰할 수 있는 기관의 보안 타임스탬프를 포함할 수 있습니다. 이 정보가 있으면 검증자가 서명 이력을 더 상세히 추적할 수 있습니다. 문서 수준 속성은 메타데이터 설정 및 편집 가이드에서 별도로 다룹니다.
다음 예제는 이 메타데이터, SHA-256 서명 다이제스트 및 DigiCert 타임스탬프 서버의 타임스탬프를 기존 PDF에 추가합니다.
using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
using System;
// Load an existing PDF document to be signed.
var pdf = PdfDocument.FromFile("invoice.pdf");
// Create a PdfSignature object directly from the certificate file and password.
var signature = new PdfSignature("IronSoftware.pfx", "123456");
// Add detailed metadata to the signature for a comprehensive audit trail.
// These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now;
signature.SigningContact = "legal@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "Contractual Agreement";
// Choose the hash algorithm for the signature digest.
// SHA-256 is the default, and SHA-384 and SHA-512 are also available
signature.SignatureHashAlgorithm = SignatureHashAlgorithms.SHA256;
// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = "http://timestamp.digicert.com";
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;
// Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, new Rectangle(350, 750, 200, 100));
// Sign the PDF document with the configured signature object.
pdf.Sign(signature);
// Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf");using IronPdf;
using IronPdf.Signing;
using IronSoftware.Drawing;
using System;
// Load an existing PDF document to be signed.
var pdf = PdfDocument.FromFile("invoice.pdf");
// Create a PdfSignature object directly from the certificate file and password.
var signature = new PdfSignature("IronSoftware.pfx", "123456");
// Add detailed metadata to the signature for a comprehensive audit trail.
// These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now;
signature.SigningContact = "legal@ironsoftware.com";
signature.SigningLocation = "Chicago, USA";
signature.SigningReason = "Contractual Agreement";
// Choose the hash algorithm for the signature digest.
// SHA-256 is the default, and SHA-384 and SHA-512 are also available
signature.SignatureHashAlgorithm = SignatureHashAlgorithms.SHA256;
// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = "http://timestamp.digicert.com";
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256;
// Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, new Rectangle(350, 750, 200, 100));
// Sign the PDF document with the configured signature object.
pdf.Sign(signature);
// Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf");Imports IronPdf
Imports IronPdf.Signing
Imports IronSoftware.Drawing
Imports System
' Load an existing PDF document to be signed.
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Create a PdfSignature object directly from the certificate file and password.
Dim signature = New PdfSignature("IronSoftware.pfx", "123456")
' Add detailed metadata to the signature for a comprehensive audit trail.
' These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now
signature.SigningContact = "legal@ironsoftware.com"
signature.SigningLocation = "Chicago, USA"
signature.SigningReason = "Contractual Agreement"
' Choose the hash algorithm for the signature digest.
' SHA-256 is the default, and SHA-384 and SHA-512 are also available
signature.SignatureHashAlgorithm = SignatureHashAlgorithms.SHA256
' Add a secure timestamp from a trusted Time Stamp Authority (TSA).
' This provides cryptographic proof of the signing time.
signature.TimeStampUrl = "http://timestamp.digicert.com"
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256
' Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = New PdfSignatureImage("assets/visual-signature.png", 0, New Rectangle(350, 750, 200, 100))
' Sign the PDF document with the configured signature object.
pdf.Sign(signature)
' Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf")Imports IronPdf
Imports IronPdf.Signing
Imports IronSoftware.Drawing
Imports System
' Load an existing PDF document to be signed.
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Create a PdfSignature object directly from the certificate file and password.
Dim signature = New PdfSignature("IronSoftware.pfx", "123456")
' Add detailed metadata to the signature for a comprehensive audit trail.
' These properties enhance the signature's credibility and provide context
signature.SignatureDate = DateTime.Now
signature.SigningContact = "legal@ironsoftware.com"
signature.SigningLocation = "Chicago, USA"
signature.SigningReason = "Contractual Agreement"
' Choose the hash algorithm for the signature digest.
' SHA-256 is the default, and SHA-384 and SHA-512 are also available
signature.SignatureHashAlgorithm = SignatureHashAlgorithms.SHA256
' Add a secure timestamp from a trusted Time Stamp Authority (TSA).
' This provides cryptographic proof of the signing time.
signature.TimeStampUrl = "http://timestamp.digicert.com"
signature.TimestampHashAlgorithm = TimestampHashAlgorithms.SHA256
' Apply a visual appearance to the signature. (More on this in the next section)
signature.SignatureImage = New PdfSignatureImage("assets/visual-signature.png", 0, New Rectangle(350, 750, 200, 100))
' Sign the PDF document with the configured signature object.
pdf.Sign(signature)
' Save the final, signed PDF document.
pdf.SaveAs("DetailedSignature.pdf")두 개의 독립적인 설정이 해싱을 제어합니다.
PdfSignature 속성 | 해시 대상 | 값 |
|---|---|---|
SignatureHashAlgorithm | 서명 자체의 PKCS#7/CMS 다이제스트 | SHA256, SHA384, SHA512, SHA1 |
TimestampHashAlgorithm | TimeStampUrl에 지정된 타임스탬프 기관으로 전송하는 RFC 3161 메시지 임프린트 | SHA256, SHA512, SHA1 |
SHA-256은 서명 다이제스트와 타임스탬프 임프린트 모두에 대한 기본값입니다. 새로운 서명에 SHA-1을 사용하지 마십시오. 암호학적으로 약하며, 예제에서 사용된 DigiCert 타임스탬프 서버는 SHA-1 임프린트 요청을 거부합니다. 두 속성을 명시적으로 설정하면, 예제에서처럼 검토자가 확인할 수 있는 코드에 선택 사항을 기록하게 됩니다.
타임스탬프 URL은 TSA 엔드포인트를 문자열로 사용합니다. URL과 타임스탬프 해시 설정은 HSM으로 서명할 때도 사용 가능하여, 하드웨어 토큰으로 서명된 문서에도 신뢰할 수 있는 타임스탬프를 포함할 수 있습니다.
Adobe Acrobat과 같은 뷰어는 서명 인증서가 신뢰 목록에 없으면 서명의 유효성을 확인할 수 없다고 표시합니다. 인증서를 목록에 추가하면 녹색 체크 표시와 함께 유효한 서명으로 표시됩니다.
디지털 서명에 시각적 표현을 추가하려면 어떻게 해야 하나요?
디지털 서명은 파일 구조에 저장되며 그 자체로는 페이지에 표시되지 않습니다. 페이지에 표시하려면 회사 로고나 자필 서명과 같은 이미지를 PdfSignature 객체에 첨부하세요.
이미지는 파일이나 스트림에서 불러올 수 있으며 원하는 페이지의 지정된 위치에 배치할 수 있습니다. 지원되는 이미지 형식은 PNG, JPEG, GIF, BMP, TIFF 및 WebP입니다. 이 방식은 PDF 문서에 텍스트와 이미지 스탬프를 추가하는 방법과 유사합니다.
using IronPdf.Signing;
using IronSoftware.Drawing;
// This example demonstrates various ways to add a visual image to a PDF signature.
// Create a PdfSignature object.
var signature = new PdfSignature("IronSoftware.pfx", "123456");
// Define the position and size for the signature image on the first page (index 0).
// Rectangle parameters: x position, y position, width, height
var signatureRectangle = new Rectangle(350, 750, 200, 100);
// Option 1: Set the SignatureImage property directly.
// This is the most straightforward approach
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle);
// Option 2: Use the LoadSignatureImageFromFile method.
// This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle);
// Option 3: Load an image from a stream. This is useful for images generated in memory.
// Perfect for scenarios where images are retrieved from databases or web services
AnyBitmap image = AnyBitmap.FromFile("assets/visual-signature.png");
using (var imageStream = image.ToStream())
{
signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle);
}
// After configuring the signature image, apply it to a PDF.
var pdf = PdfDocument.FromFile("invoice.pdf");
pdf.Sign(signature);
pdf.SaveAs("VisualSignature.pdf");using IronPdf.Signing;
using IronSoftware.Drawing;
// This example demonstrates various ways to add a visual image to a PDF signature.
// Create a PdfSignature object.
var signature = new PdfSignature("IronSoftware.pfx", "123456");
// Define the position and size for the signature image on the first page (index 0).
// Rectangle parameters: x position, y position, width, height
var signatureRectangle = new Rectangle(350, 750, 200, 100);
// Option 1: Set the SignatureImage property directly.
// This is the most straightforward approach
signature.SignatureImage = new PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle);
// Option 2: Use the LoadSignatureImageFromFile method.
// This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle);
// Option 3: Load an image from a stream. This is useful for images generated in memory.
// Perfect for scenarios where images are retrieved from databases or web services
AnyBitmap image = AnyBitmap.FromFile("assets/visual-signature.png");
using (var imageStream = image.ToStream())
{
signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle);
}
// After configuring the signature image, apply it to a PDF.
var pdf = PdfDocument.FromFile("invoice.pdf");
pdf.Sign(signature);
pdf.SaveAs("VisualSignature.pdf");Imports IronPdf.Signing
Imports IronSoftware.Drawing
' This example demonstrates various ways to add a visual image to a PDF signature.
' Create a PdfSignature object.
Dim signature As New PdfSignature("IronSoftware.pfx", "123456")
' Define the position and size for the signature image on the first page (index 0).
' Rectangle parameters: x position, y position, width, height
Dim signatureRectangle As New Rectangle(350, 750, 200, 100)
' Option 1: Set the SignatureImage property directly.
' This is the most straightforward approach
signature.SignatureImage = New PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle)
' Option 2: Use the LoadSignatureImageFromFile method.
' This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle)
' Option 3: Load an image from a stream. This is useful for images generated in memory.
' Perfect for scenarios where images are retrieved from databases or web services
Dim image As AnyBitmap = AnyBitmap.FromFile("assets/visual-signature.png")
Using imageStream = image.ToStream()
signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle)
End Using
' After configuring the signature image, apply it to a PDF.
Dim pdf As PdfDocument = PdfDocument.FromFile("invoice.pdf")
pdf.Sign(signature)
pdf.SaveAs("VisualSignature.pdf")Imports IronPdf.Signing
Imports IronSoftware.Drawing
' This example demonstrates various ways to add a visual image to a PDF signature.
' Create a PdfSignature object.
Dim signature As New PdfSignature("IronSoftware.pfx", "123456")
' Define the position and size for the signature image on the first page (index 0).
' Rectangle parameters: x position, y position, width, height
Dim signatureRectangle As New Rectangle(350, 750, 200, 100)
' Option 1: Set the SignatureImage property directly.
' This is the most straightforward approach
signature.SignatureImage = New PdfSignatureImage("assets/visual-signature.png", 0, signatureRectangle)
' Option 2: Use the LoadSignatureImageFromFile method.
' This method provides the same functionality with a different syntax
signature.LoadSignatureImageFromFile("assets/visual-signature.png", 0, signatureRectangle)
' Option 3: Load an image from a stream. This is useful for images generated in memory.
' Perfect for scenarios where images are retrieved from databases or web services
Dim image As AnyBitmap = AnyBitmap.FromFile("assets/visual-signature.png")
Using imageStream = image.ToStream()
signature.LoadSignatureImageFromStream(imageStream, 0, signatureRectangle)
End Using
' After configuring the signature image, apply it to a PDF.
Dim pdf As PdfDocument = PdfDocument.FromFile("invoice.pdf")
pdf.Sign(signature)
pdf.SaveAs("VisualSignature.pdf")이 코드는 파일 경로를 전달하는 방법, LoadSignatureImageFromFile을 사용하는 방법, 스트림을 전달하는 방법을 보여줍니다. 세 방법 모두 같은 결과를 냅니다. 서명할 때 이미지가 페이지에 표시되므로 시각적 표시와 암호학적 서명이 함께 적용됩니다.
이름이 지정된 기존 서명 필드에 서명하는 방법
이미 이름과 위치가 지정된 서명란이 있는 양식을 받을 수 있습니다. 예를 들어 정부 기관의
양식에는 작성자용 서명란과 승인자용 서명란이 따로 있을 수 있습니다.
SignatureFieldName에 해당 필드의 이름을 지정하면 IronPDF가 기존 필드에 서명을 채웁니다.
따라서 새 필드를 추가하는 대신 양식 작성자가 지정한 위치와 모양을 유지합니다.
using IronPdf;
using IronPdf.Signing;
// A form that already contains named signature blocks
PdfDocument pdf = PdfDocument.FromFile("dd-form-200.pdf");
PdfSignature signature = new PdfSignature("cert.pfx", "password")
{
// Name of an existing, unsigned signature field
SignatureFieldName = "ApproverSignature"
};
// Fills that field where the form author placed it
pdf.Sign(signature);
pdf.SaveAs("signed.pdf");using IronPdf;
using IronPdf.Signing;
// A form that already contains named signature blocks
PdfDocument pdf = PdfDocument.FromFile("dd-form-200.pdf");
PdfSignature signature = new PdfSignature("cert.pfx", "password")
{
// Name of an existing, unsigned signature field
SignatureFieldName = "ApproverSignature"
};
// Fills that field where the form author placed it
pdf.Sign(signature);
pdf.SaveAs("signed.pdf");Imports IronPdf
Imports IronPdf.Signing
' A form that already contains named signature blocks
Dim pdf As PdfDocument = PdfDocument.FromFile("dd-form-200.pdf")
Dim signature As New PdfSignature("cert.pfx", "password") With {
.SignatureFieldName = "ApproverSignature"
}
' Fills that field where the form author placed it
pdf.Sign(signature)
pdf.SaveAs("signed.pdf")Imports IronPdf
Imports IronPdf.Signing
' A form that already contains named signature blocks
Dim pdf As PdfDocument = PdfDocument.FromFile("dd-form-200.pdf")
Dim signature As New PdfSignature("cert.pfx", "password") With {
.SignatureFieldName = "ApproverSignature"
}
' Fills that field where the form author placed it
pdf.Sign(signature)
pdf.SaveAs("signed.pdf")문서에 표시된 서명 양식 필드의 Name 값을 사용하세요. 필드 이름을 설정하지 않거나
빈 값 또는 공백만 지정하면 기존 동작과 같이 새 서명 필드가 추가됩니다.
해당 이름의 서명되지 않은 필드가 없거나 같은 이름의 필드가 모두 이미 서명된 경우에는 예외가 발생합니다. 오류 메시지에 필드 이름이 표시되므로 오타를 쉽게 찾을 수 있습니다.
새 서명 필드가 추가되면 IronPDF는 Signature1, Signature2와 같은 이름을 순서대로 지정합니다.
문서에서 이미 사용 중인 이름은 건너뜁니다. 예를 들어 양식에 Signature1이라는 서명되지 않은 자리 표시자가 있으면
해당 자리 표시자는 그대로 유지되고, 새 서명에는 Signature2라는 이름이 지정됩니다.
이름이 지정된 기존 필드에 서명할 때는 SignaturePermissions가 적용되지 않습니다.
기존 필드를 채우면 인증 권한이 없는 일반 승인 서명이 생성됩니다.
따라서 필드 이름과 함께 전달한 권한 값은 오류가 되지 않으며 적용되지도 않습니다.
인증 권한은 서명 시 새 필드가 추가될 때만 적용되며, ISO 32000에서는
인증 서명이 문서에서 처음으로 서명되는 필드에 있어야 한다고 규정합니다.
IronPdfEngine 또는 Docker를 사용하는 배포 환경에는 이 기능을 지원하는 엔진 빌드가 필요합니다. 이전 엔진은 필드 이름을 인식하지 못해 별도 알림 없이 새 필드를 추가하며, 지정된 서명란은 비어 있게 됩니다. 엔진 버전을 라이브러리 버전에 맞추세요.
SignatureImage를 사용하여 서명할 수 없습니다. 이미지를 적용하면 양식 작성자가 배치한 서명란의 위치가 바뀌므로, 이 조합을 사용하면 NotSupportedException이 발생합니다. 기존 필드에는 이미지 없이 서명하세요. 또는 필드 이름을 설정하지 않고 새 필드를 추가하면 위치를 자유롭게 지정할 수 있습니다.서명 후 문서 권한을 어떻게 관리할 수 있나요?
문서에 서명할 때 서명 이후에 허용할 변경 사항을 지정할 수 있습니다. 예를 들어 문서를 완전히 잠그거나 양식 작성과 추가 서명만 허용할 수 있습니다. IronPDF는 Sign의 두 번째 인수로 전달하는 SignaturePermissions 열거형으로 권한을 설정합니다. 이 인수를 생략하면 NoChangesAllowed가 적용됩니다. 비밀번호로 제한하려면 PDF 비밀번호 및 권한 설정 가이드를 참조하세요.
이 값은 ISO 32000에서 정의한 표준 PDF DocMDP 인증 권한으로, 서명 자체에 기록됩니다. 각 값은 이후 문서를 다루는 사람이 이 서명을 무효화하지 않고 수행할 수 있는 작업을 지정합니다. 표준을 준수하는 뷰어는 그 밖의 변경 사항이 있으면 이 서명을 무효로 판정합니다.
SignaturePermissions 멤버 | DocMDP 수준 | 이후 허용되는 작업 |
|---|---|---|
NoChangesAllowed | 1 | 없음. 문서는 실질적으로 잠겨 있습니다. |
AdditionalSignaturesAndFormFillingAllowed | 2 | 추가 서명 및 양식 필드 작성 |
AdditionalSignaturesFormFillingAndAnnotationsAllowed | 3 | 추가 서명, 양식 필드 작성, 주석 생성 또는 수정 |
VerifyPdfSignatures는 각 서명의 바이트 범위를 검증합니다. 권한 제한은 검증 대상에 포함되지 않으므로 Adobe Acrobat처럼 표준을 준수하는 뷰어에서 확인하세요.한 번 저장할 때 서명을 몇 개까지 추가할 수 있습니까?
한 개입니다. PdfDocument는 저장할 때마다 새 서명을 하나만 허용합니다.
증분 저장 여부와 관계없이, 열려 있는 동일한 문서에 두 번째 서명을 추가하면
즉시 NotSupportedException이 발생합니다.
이 제한은 PDF 서명 방식 자체에서 비롯됩니다. 각 서명은 자신의 자리 표시자까지 파일 내용을 포함합니다. 따라서 같은 수정본에 두 번째 서명을 추가하면 첫 번째 서명이 이미 포함한 바이트가 바뀌어 마지막 서명만 검증할 수 있습니다. 이전 버전에서는 이 패턴을 허용하여 앞선 서명들이 별도 알림 없이 무효가 된 문서를 생성했습니다. 이제는 두 번째 서명 추가를 거부합니다.
따라서 pdf.Sign(a).Sign(b).SaveAs(...) 방식으로는 더 이상 서명할 수 없습니다.
같은 객체에서 서명 메서드를 두 번 호출하는 경우에도 마찬가지입니다.
여러 당사자가 동일한 문서에 서명하는 방법은 무엇인가요?
여러 당사자가 같은 문서에 서명할 수 있습니다. 수정본당 서명 하나가 허용되므로 한 문서에는 서명이 여러 개 있을 수 있습니다. 다음 코드에서는 각 당사자가 별도의 증분 수정본에 서명합니다.
using IronPdf.Signing;
PdfDocument.FromFile("form.pdf")
.Sign(signatureA, SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed)
.SaveAs("step1.pdf");
PdfDocument.FromFile("step1.pdf").Sign(signatureB).SaveAsRevision("step2.pdf");using IronPdf.Signing;
PdfDocument.FromFile("form.pdf")
.Sign(signatureA, SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed)
.SaveAs("step1.pdf");
PdfDocument.FromFile("step1.pdf").Sign(signatureB).SaveAsRevision("step2.pdf");Imports IronPdf.Signing
PdfDocument.FromFile("form.pdf").Sign(signatureA, SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed).SaveAs("step1.pdf")
PdfDocument.FromFile("step1.pdf").Sign(signatureB).SaveAsRevision("step2.pdf")Imports IronPdf.Signing
PdfDocument.FromFile("form.pdf").Sign(signatureA, SignaturePermissions.AdditionalSignaturesAndFormFillingAllowed).SaveAs("step1.pdf")
PdfDocument.FromFile("step1.pdf").Sign(signatureB).SaveAsRevision("step2.pdf")수정 이력에는 각각 서명 하나가 포함된 두 수정본이 남으며, 두 서명 모두 검증할 수 있습니다.
첫 번째 서명에 AdditionalSignaturesAndFormFillingAllowed를 설정하면
첫 번째 서명을 무효화하지 않고 두 번째 당사자의 수정본을 추가할 수 있습니다.
증분 저장을 사용하면 이전 바이트를 그대로 유지하면서 저장할 때마다 새 수정본을 추가할 수 있습니다. 두 번째 당사자가 저장하면 해당 서명은 새 수정본으로 기록됩니다. 첫 번째 서명은 기존에 서명한 바이트에 계속 적용되므로 문서는 여러 승인 단계를 거칠 수 있습니다. Adobe Acrobat에서는 서명 대상 수정본을 현재 버전과 비교하여 서명 이후의 변경 사항을 확인할 수 있습니다. 증분 저장에 대한 자세한 내용은 PDF 수정 이력 관리 가이드를 참조하세요.
SaveAsRevision("step2.pdf")는 수정본을 디스크에 직접 저장합니다. 경로 없이 호출하면 수정본을 메모리에 반환하며, 나중에 SaveAs로 저장할 수 있습니다.여러 버전에 걸쳐 서명을 관리하고 검증하려면 어떻게 해야 하나요?
PDF 문서에는 여러 수정본에 걸쳐 서명이 포함될 수 있습니다. IronPDF는 수정 이력을 다루는 다음 메서드를 제공합니다.
- 이전 수정본으로 롤백.
GetRevision메서드는 이전 수정본의 상태를 별도 문서로 반환합니다. 이후에 추가된 변경 사항과 서명은 이 문서에 포함되지 않습니다.RevisionCount는 파일에 포함된 수정본의 수를 반환합니다. - 모든 서명 검증.
VerifyPdfSignatures메서드는 문서의 모든 수정본에 포함된 모든 서명을 검증합니다. 모든 서명이 유효하면 true를 반환합니다. 유효하지 않은 서명이 하나라도 있거나 문서에 서명이 없으면 false를 반환합니다. 정적PdfDocument.VerifyPdfSignaturesInFile메서드는 문서 전체를 로드하지 않고 파일 경로를 받아 같은 검사를 수행합니다. - 증분 변조 감지.
detectIncrementalTampering인수는 수정본 단위의 변조 검사를 추가합니다. 처리 시간이 늘어나므로 기본적으로 비활성화되어 있습니다. - 서명 제거.
RemoveSignatures메서드는 문서의 모든 수정본에서 디지털 서명을 제거하여 서명 없는 버전을 만듭니다.
변조 검사는 위의 검증 메서드와 GetVerifiedSignatures에서 사용할 수 있습니다. 이후의 증분 업데이트가 앞선 서명의 적용 대상 객체를 몰래 재정의하는 섀도 공격을 감지합니다. 문서가 크거나 수정 이력이 많으면 처리 시간 증가가 더 두드러집니다. IronPDF API 레퍼런스에서는 법률 및 정부 분야에서 여러 서명이 필요한 워크플로에 이 검사를 권장합니다.
// Load a PDF with a complex signature history.
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");
// Verify all signatures across all revisions.
// This ensures document integrity throughout its entire history
bool allSignaturesValid = pdf.VerifyPdfSignatures(detectIncrementalTampering: true);
Console.WriteLine($"All signatures are valid: {allSignaturesValid}");
// Roll back to the first revision (index 0).
// Useful for reviewing the original document state
if (pdf.RevisionCount > 1)
{
PdfDocument firstRevision = pdf.GetRevision(0);
firstRevision.SaveAs("report_first_revision.pdf");
}
// Create a completely unsigned version of the document.
// This removes all digital signatures while preserving content
pdf.RemoveSignatures();
pdf.SaveAs("report_unsigned.pdf");// Load a PDF with a complex signature history.
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");
// Verify all signatures across all revisions.
// This ensures document integrity throughout its entire history
bool allSignaturesValid = pdf.VerifyPdfSignatures(detectIncrementalTampering: true);
Console.WriteLine($"All signatures are valid: {allSignaturesValid}");
// Roll back to the first revision (index 0).
// Useful for reviewing the original document state
if (pdf.RevisionCount > 1)
{
PdfDocument firstRevision = pdf.GetRevision(0);
firstRevision.SaveAs("report_first_revision.pdf");
}
// Create a completely unsigned version of the document.
// This removes all digital signatures while preserving content
pdf.RemoveSignatures();
pdf.SaveAs("report_unsigned.pdf");' Load a PDF with a complex signature history.
Dim pdf = PdfDocument.FromFile("multi_signed_report.pdf")
' Verify all signatures across all revisions.
' This ensures document integrity throughout its entire history
Dim allSignaturesValid As Boolean = pdf.VerifyPdfSignatures(detectIncrementalTampering:=True)
Console.WriteLine($"All signatures are valid: {allSignaturesValid}")
' Roll back to the first revision (index 0).
' Useful for reviewing the original document state
If pdf.RevisionCount > 1 Then
Dim firstRevision As PdfDocument = pdf.GetRevision(0)
firstRevision.SaveAs("report_first_revision.pdf")
End If
' Create a completely unsigned version of the document.
' This removes all digital signatures while preserving content
pdf.RemoveSignatures()
pdf.SaveAs("report_unsigned.pdf")' Load a PDF with a complex signature history.
Dim pdf = PdfDocument.FromFile("multi_signed_report.pdf")
' Verify all signatures across all revisions.
' This ensures document integrity throughout its entire history
Dim allSignaturesValid As Boolean = pdf.VerifyPdfSignatures(detectIncrementalTampering:=True)
Console.WriteLine($"All signatures are valid: {allSignaturesValid}")
' Roll back to the first revision (index 0).
' Useful for reviewing the original document state
If pdf.RevisionCount > 1 Then
Dim firstRevision As PdfDocument = pdf.GetRevision(0)
firstRevision.SaveAs("report_first_revision.pdf")
End If
' Create a completely unsigned version of the document.
' This removes all digital signatures while preserving content
pdf.RemoveSignatures()
pdf.SaveAs("report_unsigned.pdf")PDF 파일에 자필 서명을 찍으려면 어떻게 해야 하나요?
송장에 스캔한 자필 서명을 표시하는 경우처럼, 디지털 서명의 암호학적 보호 없이 눈에 보이는 서명만 필요한 문서도 있습니다. 이 작업을 스탬프 적용이라고 하며, IronPDF에서는 HtmlStamper 클래스와 ApplyStamp 메서드를 사용합니다. 스탬프와 워터마크 옵션에 대한 자세한 내용은 사용자 지정 워터마크 가이드를 참조하세요.
이 예제에서는 샘플 송장 PDF와 자필 서명 PNG 이미지를 사용합니다.
자필 서명 스탬프를 추가하기 전의 원본 송장 PDF.
다음 이미지는 적용할 서명입니다.
자필 서명 샘플 이미지.
다음 코드는 이 이미지를 HTML 스탬퍼에 넣어 모든 페이지의 오른쪽 하단에 스탬프로 추가합니다.
using IronPdf;
using IronPdf.Editing;
// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");
// Create an HtmlStamper containing our signature image.
// HtmlStamper allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamper("<img src='assets/signature.png'/>")
{
// Configure the stamp's position and appearance.
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
HorizontalOffset = new Length(-10, MeasurementUnit.Pixel), // Add some space from the edge.
VerticalOffset = new Length(-10, MeasurementUnit.Pixel),
Opacity = 90 // Make it slightly transparent for a more authentic look.
};
// Apply the stamp to all pages of the PDF.
// You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp);
// Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf");using IronPdf;
using IronPdf.Editing;
// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");
// Create an HtmlStamper containing our signature image.
// HtmlStamper allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamper("<img src='assets/signature.png'/>")
{
// Configure the stamp's position and appearance.
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
HorizontalOffset = new Length(-10, MeasurementUnit.Pixel), // Add some space from the edge.
VerticalOffset = new Length(-10, MeasurementUnit.Pixel),
Opacity = 90 // Make it slightly transparent for a more authentic look.
};
// Apply the stamp to all pages of the PDF.
// You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp);
// Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf");Imports IronPdf
Imports IronPdf.Editing
' Load the existing PDF document.
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Create an HtmlStamper containing our signature image.
' HtmlStamper allows us to position HTML content precisely on the page
Dim signatureStamp = New HtmlStamper("<img src='assets/signature.png'/>") With {
' Configure the stamp's position and appearance.
.VerticalAlignment = VerticalAlignment.Bottom,
.HorizontalAlignment = HorizontalAlignment.Right,
.HorizontalOffset = New Length(-10, MeasurementUnit.Pixel), ' Add some space from the edge.
.VerticalOffset = New Length(-10, MeasurementUnit.Pixel),
.Opacity = 90 ' Make it slightly transparent for a more authentic look.
}
' Apply the stamp to all pages of the PDF.
' You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp)
' Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf")Imports IronPdf
Imports IronPdf.Editing
' Load the existing PDF document.
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Create an HtmlStamper containing our signature image.
' HtmlStamper allows us to position HTML content precisely on the page
Dim signatureStamp = New HtmlStamper("<img src='assets/signature.png'/>") With {
' Configure the stamp's position and appearance.
.VerticalAlignment = VerticalAlignment.Bottom,
.HorizontalAlignment = HorizontalAlignment.Right,
.HorizontalOffset = New Length(-10, MeasurementUnit.Pixel), ' Add some space from the edge.
.VerticalOffset = New Length(-10, MeasurementUnit.Pixel),
.Opacity = 90 ' Make it slightly transparent for a more authentic look.
}
' Apply the stamp to all pages of the PDF.
' You can also specify specific page numbers if needed
pdf.ApplyStamp(signatureStamp)
' Save the modified PDF document.
pdf.SaveAs("official_invoice.pdf")스탬프가 찍힌 PDF 결과물은 어떤 모습인가요?
코드를 실행하면 송장에 서명 이미지가 표시됩니다.
오른쪽 하단에 자필 서명 이미지를 스탬프로 추가한 최종 PDF.
PDF에 대화형 서명 필드를 추가하려면 어떻게 해야 하나요?
수신자가 Adobe Acrobat과 같은 PDF 뷰어에서 서명해야 한다면 대화형 서명 양식 필드를 추가하세요. 수신자는 이 빈 영역을 클릭하여 자신의 디지털 서명을 적용할 수 있습니다. PDF 양식에 대한 자세한 내용은 PDF 양식 만들기 튜토리얼을 참조하세요.
이름, 페이지 인덱스, 위치 및 크기를 지정하여 SignatureFormField를 생성한 뒤 PDF의 양식 컬렉션에 추가하세요. 여러 서명이나 외부 당사자의 서명이 필요한 문서에는 별도의 필드를 사용하세요.
using IronSoftware.Forms;
// Create a new PDF to add the signature field to.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Please Sign Below</h1>");
// Define the properties for the signature form field.
string fieldName = "ClientSignature"; // Unique identifier for the field
uint pageIndex = 0; // Add to the first page (zero-indexed)
// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, 50, 200, 300, 100); // Position: (x, y), Size: (width, height)
// Add the signature field to the PDF's form.
pdf.Form.Add(signatureField);
// Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf");using IronSoftware.Forms;
// Create a new PDF to add the signature field to.
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Please Sign Below</h1>");
// Define the properties for the signature form field.
string fieldName = "ClientSignature"; // Unique identifier for the field
uint pageIndex = 0; // Add to the first page (zero-indexed)
// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, 50, 200, 300, 100); // Position: (x, y), Size: (width, height)
// Add the signature field to the PDF's form.
pdf.Form.Add(signatureField);
// Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf");Imports IronSoftware.Forms
' Create a new PDF to add the signature field to.
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Please Sign Below</h1>")
' Define the properties for the signature form field.
Dim fieldName As String = "ClientSignature" ' Unique identifier for the field
Dim pageIndex As UInteger = 0 ' Add to the first page (zero-indexed)
' Create the SignatureFormField object.
' This creates an interactive field that users can click to sign
Dim signatureField = New SignatureFormField(fieldName, pageIndex, 50, 200, 300, 100) ' Position: (x, y), Size: (width, height)
' Add the signature field to the PDF's form.
pdf.Form.Add(signatureField)
' Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf")Imports IronSoftware.Forms
' Create a new PDF to add the signature field to.
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Please Sign Below</h1>")
' Define the properties for the signature form field.
Dim fieldName As String = "ClientSignature" ' Unique identifier for the field
Dim pageIndex As UInteger = 0 ' Add to the first page (zero-indexed)
' Create the SignatureFormField object.
' This creates an interactive field that users can click to sign
Dim signatureField = New SignatureFormField(fieldName, pageIndex, 50, 200, 300, 100) ' Position: (x, y), Size: (width, height)
' Add the signature field to the PDF's form.
pdf.Form.Add(signatureField)
' Save the PDF with the new interactive signature field.
pdf.SaveAs("interactive_signature.pdf")
코드로 PDF 문서에 추가한 서명되지 않은 대화형 서명 필드.
검증된 서명에서 서명자 이름을 어떻게 확인할 수 있나요?
서명자의 이름을 가져오려면 다음 예제처럼 VerifiedSignature 클래스의 SignerName 속성을 읽으세요.
using IronPdf;
using System;
// Import the Signed PDF report
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");
// Using GetVerifiedSignatures() obtain a list of `VerifiedSignature` objects from the PDF
pdf.GetVerifiedSignatures().ForEach(signature =>
{
// Print out the SignerName of each `VerifiedSignature` object
Console.WriteLine($"SignatureName: {signature.SignerName}");
});using IronPdf;
using System;
// Import the Signed PDF report
var pdf = PdfDocument.FromFile("multi_signed_report.pdf");
// Using GetVerifiedSignatures() obtain a list of `VerifiedSignature` objects from the PDF
pdf.GetVerifiedSignatures().ForEach(signature =>
{
// Print out the SignerName of each `VerifiedSignature` object
Console.WriteLine($"SignatureName: {signature.SignerName}");
});Imports IronPdf
Imports System
' Import the Signed PDF report
Dim pdf = PdfDocument.FromFile("multi_signed_report.pdf")
' Using GetVerifiedSignatures() obtain a list of `VerifiedSignature` objects from the PDF
pdf.GetVerifiedSignatures().ForEach(Sub(signature)
' Print out the SignerName of each `VerifiedSignature` object
Console.WriteLine($"SignatureName: {signature.SignerName}")
End Sub)Imports IronPdf
Imports System
' Import the Signed PDF report
Dim pdf = PdfDocument.FromFile("multi_signed_report.pdf")
' Using GetVerifiedSignatures() obtain a list of `VerifiedSignature` objects from the PDF
pdf.GetVerifiedSignatures().ForEach(Sub(signature)
' Print out the SignerName of each `VerifiedSignature` object
Console.WriteLine($"SignatureName: {signature.SignerName}")
End Sub)서명된 PDF 파일을 불러온 뒤 GetVerifiedSignatures() 메서드를 호출하여 검증된 서명 목록을 가져오고 각 서명자의 이름을 출력합니다.
서명자 이름은 서명 사전에서 읽습니다. 이 값이 없으면 인증서의 주체 식별 이름(SubjectDN)에 있는 CN 필드를 사용합니다. 두 곳 모두에 값이 없으면 빈 문자열을 반환합니다.
검증된 각 서명은 검증 결과를 나타내는 Valid와 Status, 서명 인증서의 X.509 상세 정보(주체 및 발급자 DN, 일련 번호, 유효 기간, SHA-256 지문)를 제공하는 SignerCertificate, 서명자부터 루트까지의 인증서 체인을 제공하는 CertificateChain을 노출합니다. 검증된 PDF 서명에서 서명자 인증서 읽기 가이드에서는 국가 신분증 식별자 추출, 인증서 피닝 및 체인 순회를 자세히 설명합니다.
IronPDF로 PDF에 서명한 후의 다음 단계
이 가이드에서는 메타데이터와 타임스탬프가 포함된 인증서 기반 디지털 서명, 서명 권한, 여러 수정본에 걸친 다자간 서명, 서명 검증, 자필 서명 스탬프 및 대화형 서명 필드를 다뤘습니다.
프로젝트에서 이 예제를 사용하려면 IronPDF for .NET 라이브러리를 다운로드하고 무료 체험 라이선스를 받으세요. 관련 가이드에서는 주석 추가와 양식 필드 작업을 다룹니다. PDF 서명 및 보안 튜토리얼에서는 서명, 비밀번호 및 권한을 함께 설명합니다. IronPDF는 Iron Suite에도 포함됩니다. Iron Suite는 한 번 구매하면 라이선스 키 하나로 Iron Software의 .NET 라이브러리 10개를 사용할 수 있는 제품군입니다.
자주 묻는 질문
IronPDF를 사용하여 인증서로 PDF에 디지털 서명을 하려면 어떻게 해야 하나요?
인증서를 Exportable 저장 플래그와 함께 X509Certificate2 객체에 로드하고, 이를 새로운 PdfSignature에 전달한 후 저장하기 전에 PdfDocument에서 Sign을 호출하세요. SignWithFile은 .pfx 또는 .p12 경로에서 한 번의 호출로 동일한 작업을 수행하고, SignWithStore는 인증서 저장소에서 지문으로 식별된 인증서로 서명합니다.
IronPDF에서 디지털 서명으로서의 시각적 이미지를 추가하는 단계는 무엇인가요?
인증서를 사용하여 PdfSignature를 작성하고 SignatureImage 속성에 페이지 인덱스와 위치 및 크기에 대한 직사각형을 지정하여 PdfSignatureImage를 할당하세요. LoadSignatureImageFromFile과 LoadSignatureImageFromStream은 파일 경로나 스트림에서 동일한 작업을 수행합니다. PNG, JPEG, GIF, BMP, TIFF 및 WebP 이미지가 지원되며, 서명할 때 문서 페이지에 이미지가 그려집니다.
IronPDF에서 PDF에 대화형 서명 필드를 추가할 수 있나요?
네. 이름, 페이지 인덱스, 위치 및 크기를 가진 SignatureFormField를 생성한 다음 pdf.Form.Add로 문서에 추가합니다. 저장된 PDF에는 수신자가 Adobe Acrobat과 같은 뷰어에서 서명할 수 있는 빈 클릭 가능한 서명 필드가 포함됩니다.
IronPDF는 PDF 문서의 모든 서명을 확인하기 위해 어떤 메소드를 제공하나요?
VerifyPdfSignatures는 모든 수정본에 걸친 모든 서명을 검사하며, 모두 유효한 경우에만 true를 반환합니다. PdfDocument.VerifyPdfSignaturesInFile은 파일 경로에 대해 동일한 검사를 수행합니다. 각 서명에 대한 세부 정보는 GetVerifiedSignatures가 서명당 하나의 VerifiedSignature를 반환합니다. 두 메서드의 detectIncrementalTampering 인수를 true로 설정하면 이전 서명이 적용된 이후에 재정의된 개체를 감지하는 수정 레벨 분석이 추가됩니다.
IronPDF를 사용하여 PDF에 서명한 후 문서 권한을 어떻게 관리할 수 있나요?
Sign의 두 번째 인수로 SignaturePermissions 값을 전달합니다. NoChangesAllowed는 문서를 잠그고 기본값이며, AdditionalSignaturesAndFormFillingAllowed는 추가 서명 및 양식 채우기를 허용하며, AdditionalSignaturesFormFillingAndAnnotationsAllowed는 주석도 허용합니다. 이러한 값은 ISO 32000에 의해 정의된 DocMDP 레벨 1, 2 및 3이며, PDF 리더가 이를 준수합니다.
서명과 타임스탬프에 IronPDF는 어떤 해시 알고리즘을 사용하나요?
SignatureHashAlgorithm은 서명 다이제스트를 설정하며, SHA-256, SHA-384, SHA-512 또는 SHA-1을 수용합니다. TimestampHashAlgorithm은 RFC 3161 도장을 TimeStampUrl의 타임스탬프 권한에 보낼 때 설정하며, SHA-256, SHA-512 또는 SHA-1을 수용합니다. 둘 다 기본적으로 SHA-256을 사용합니다. SHA-1은 암호적으로 약하며 새로운 서명에 사용해서는 안 되며, DigiCert을 포함한 일부 타임스탬프 권한은 이를 거부합니다.
IronPDF는 PDF에 손으로 쓴 것처럼 보이는 서명을 추가하기 위해 어떤 기능을 제공하나요?
HtmlStamper 클래스를 사용하여 서명 이미지로 가리키는 이미지 태그를 설정하고 정렬 및 오프셋을 설정한 다음 ApplyStamp로 적용합니다. 그 결과는 디지털 서명의 암호학적 보호가 없는 시각적 서명이 포함된 PDF입니다. 가시적 이미지와 디지털 서명을 결합하려면 PdfSignature의 SignatureImage 속성을 사용하세요.
IronPDF를 사용하여 PDF의 확인된 서명에서 서명자의 이름을 어떻게 호출할 수 있나요?
GetVerifiedSignatures를 호출하면 VerifiedSignature 객체 목록을 반환하며 각 객체의 SignerName 속성을 읽습니다. 서명자 이름은 서명 딕셔너리에 저장된 이름에서 가져오며, 인증서 주제의 CN 필드가 대체로 사용됩니다. SignerCertificate와 CertificateChain은 전체 인증서 세부정보와 루트까지의 체인을 제공합니다.
IronPDF에서 서명된 PDF 문서의 이전 개정판으로 롤백할 수 있나요?
네. GetRevision은 이전 수정본 시점의 서명된 PDF를 추가된 변경사항과 서명이 없는 상태의 별도의 PdfDocument로 반환하며, RevisionCount는 존재하는 수정본 수를 보고합니다. 이는 여러 승인 단계의 워크플로우에서 이전 문서 상태를 검토하는 데 유용합니다.
IronPDF를 사용하여 PDF 서명을 시작하기 위해 어떤 단계를 따라야 하나요?
NuGet에서 IronPdf 패키지를 설치하고 이 페이지의 한 줄 SignWithFile 예제부터 시작하세요. 디지털 및 시각적 서명, 서명 필드 및 서명 검증을 테스트하기 위한 무료 체험판 라이선스가 제공됩니다. IronPDF 코드 예제와 서명 및 PDF 보안 튜토리얼은 동일한 기능을 더욱 깊이 있게 다룹니다.
기존의 명명된 서명 필드에 어떻게 서명하나요?
PdfSignature에서 SignatureFieldName 속성을 기존 서명되지 않은 서명 양식 필드의 Name으로 설정하세요. IronPDF는 양식 작성자가 배치한 위치에 해당 필드를 채우며, 이는 여러 명명된 서명 블록이 있는 양식에서 필요합니다. 명명된 서명 필드가 없다면 서명에 오류가 발생하며, 오류 메시지에는 필드 이름이 포함됩니다. SignatureImage와 SignatureFieldName은 결합될 수 없습니다, 이미지를 적용하면 필드가 재배치되기 때문입니다.
PDF를 두 번 서명하면 왜 NotSupportedException이 발생하나요?
PdfDocument에는 저장당 하나의 새로운 서명만 가능합니다. 동일한 수정본에 두 번째 서명을 추가하면 첫 번째 서명이 이미 서명한 바이트가 변경되어, 마지막 서명만 검증됩니다. 이전 버전에서는 이를 허용하여 서명이 조용히 무효화된 문서를 생성했지만, 현재 버전에서는 대신 예외를 발생시킵니다. 여러 당사자가 서명하려면, 서명 후 저장하고, 파일을 다시 열고 SaveAsRevision으로 다음 서명을 추가하세요, 저장당 하나의 서명 패턴을 따릅니다.
SignaturePermissions와 저장당 하나의 서명 규칙의 차이는 무엇인가요?
그들은 별개의 개념입니다. SignaturePermissions는 ISO 32000에 의해 정의된 표준 PDF 인증 권한입니다. 서명된 문서에 기록되며 후속 당사자가 서명을 무효화하지 않고 변경할 수 있는 내용을 규정합니다. 저장당 하나의 서명 규칙은 몇 개의 Sign() 호출을 단일 저장 전에 배치할 수 있는지를 규정합니다. 추가 서명을 허용하는 권한이 두 개의 서명을 하나의 저장에 허용하는 것은 아닙니다.
명명된 필드를 서명할 때 SignaturePermissions이 적용되나요?
아니요. 미리 배치된 필드를 채우면 인증 권한이 없는 일반 승인 서명이 항상 생성되므로 SignatureFieldName과 함께 전달된 권한 값은 효과가 없습니다. 권한으로 인증하려면 필드 이름 없이 첫 번째 서명을 적용하여 서명이 새로운 필드를 추가하도록 하세요.
제이콥 멜러는 Iron Software의 최고 기술 책임자(CTO)이자 C# PDF 기술을 개척한 선구적인 엔지니어입니다. Iron Software의 핵심 코드베이스를 최초로 개발한 그는 창립 초기부터 회사의 제품 아키텍처를 설계해 왔으며, CEO인 캐머런 리밍턴과 함께 회사를 NASA, 테슬라, 그리고 전 세계 정부 기관에 서비스를 제공하는 50명 이상의 직원을 보유한 기업으로 성장시켰습니다.