A Developer's Guide to Digitally Signing PDFs with C
이 포괄적인 가이드는 C# 개발자에게 IronPDF를 사용하여 PDF에 디지털 서명을 하는 방법을 안내하며, 문서의 진위성과 보안을 보장하기 위한 인증서 기반 서명, 시각적 스탬프 및 대화형 양식 필드에 대해 다룹니다.
PDF 문서에 서명을 추가하는 것은 많은 애플리케이션에서 흔히 요구되는 기능이지만, "서명"이라는 용어는 다양한 의미를 가질 수 있습니다. 어떤 경우에는 보안 인증서를 사용하여 위변조가 불가능한 디지털 서명을 적용하는 것이 핵심입니다. 다른 경우에는 문서에 시각적인 손글씨 서명 이미지를 삽입하거나, 사용자가 전자 서명을 할 수 있도록 대화형 양식 필드를 추가하는 경우도 있습니다.
이 가이드는 C# 개발자를 대상으로 IronPDF for .NET 라이브러리를 사용하여 이러한 모든 작업을 수행하는 방법에 대한 포괄적인 안내를 제공합니다. 안전한 X509Certificate2 디지털 서명 적용부터 그래픽 서명 도장 찍기, 대화형 서명 필드 생성에 이르기까지 모든 과정을 다루어, PDF 문서의 진위성, 보안성 및 Professional함을 보장합니다.
빠른 시작: IronPDF를 사용하여 손쉽게 PDF에 디지털 서명하기
IronPDF를 사용하여 간단하고 직관적인 절차로 PDF 문서에 디지털 서명을 빠르게 시작해 보세요. 이 예제는 .pfx 인증서를 사용하여 PDF 파일을 인증하고 서명함으로써 문서의 무결성과 진위성을 보장하는 방법을 보여줍니다. 다음 단계를 따라 애플리케이션에 디지털 서명을 원활하게 통합하십시오.
최소 워크플로 (5단계)
- IronPDF for .NET 라이브러리를 설치하십시오.
-
X509Certificate2객체를 사용하여 디지털 서명을 적용합니다. - 디지털 서명을 나타내는 이미지를 추가하십시오.
- PDF 파일에 그래픽 또는 손글씨 서명을 찍습니다.
- 전자 서명을 위한 대화형 서명 양식 필드를 추가하십시오.
인증서를 사용하여 PDF에 디지털 서명을 적용하는 방법은 무엇입니까?
디지털 인증서 파일(예: .pfx 또는 .p12)을 사용하여 PDF 문서에 디지털 서명을 적용하면 문서의 진위성과 무결성을 보장할 수 있습니다. 이 프로세스는 문서가 서명된 이후 변경되지 않았음을 보장합니다. 디지털 서명 기능에 대한 전체적인 개요를 확인하려면 당사의 포괄적인 디지털 서명 가이드를 살펴보십시오.
IronPDF는 이러한 목적을 위해 직관적인 API를 제공하며, 디지털 서명을 적용하는 다양한 방법을 지원합니다. 이 기능의 핵심은 PdfSignature 클래스를 중심으로 이루어지며, 이 클래스는 인증서와 서명에 관련된 모든 메타데이터를 캡슐화합니다.
| 서명 방법 | 설명 |
|---|---|
서명 |
사용자가 생성하고 구성한 `PdfSignature` 객체를 사용하여 PDF/A에 서명합니다. |
SignWithFile |
디지털 서명 인증서 파일을 사용하여 PDF에 서명합니다 (.pfx 또는 .p12)를 사용하여 PDF에 서명합니다. |
SignWithStore |
컴퓨터의 인증서 저장소에 있는 디지털 서명을 사용하여 PDF에 서명하며, 이 서명은 썸프린트 ID로 식별됩니다. |
X509Certificate2 객체 사용
최대한의 제어를 위해 인증서 파일에서 X509Certificate2 객체를 생성할 수 있습니다. IronPDF는 X509Certificate2 표준을 완벽하게 준수하여, 디지털 서명 구현을 위한 강력하고 안전한 방법을 제공합니다. 인증서 객체를 생성할 때, 기본 암호화 API에서 요구하는 사항이므로 X509KeyStorageFlags가 Exportable로 설정되어 있는지 확인하십시오. 코드 저장소에서 디지털 서명의 실제 예제를 확인해 보십시오.
Install-Package IronPdf
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")
위의 코드는 먼저 간단한 PDF를 생성합니다. 그런 다음 .pfx 인증서 파일을 X509Certificate2 객체에 로드합니다. 디지털 신원을 나타내는 이 객체는 PdfSignature 생성자에 전달됩니다. 마지막으로, pdf.Sign 메서드는 문서를 저장하기 전에 이 서명을 문서에 적용합니다. For more information on the X509Certificate2 class, you can refer to the official Microsoft documentation.
디지털 서명에 세부 정보 추가하기
디지털 서명에는 인증서 이상의 내용이 포함될 수 있습니다; 서명에 대한 맥락을 제공하기 위해 풍부한 메타데이터를 포함할 수 있습니다. 여기에는 서명 위치, 사유, 연락처 정보 및 신뢰할 수 있는 기관에서 발급한 보안 타임스탬프가 포함됩니다. 추가 문서 속성에 대한 메타데이터를 설정하고 편집할 수도 있습니다.
이러한 세부 정보를 추가하면 문서의 감사 추적이 개선되고 검증자에게 유용한 정보를 제공할 수 있습니다. IronPDF는 최신 SHA256 및 SHA512 해시 알고리즘을 사용하는 타임스탬프 서버도 지원합니다.
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";
// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = new Uri("[http://timestamp.digicert.com](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";
// Add a secure timestamp from a trusted Time Stamp Authority (TSA).
// This provides cryptographic proof of the signing time.
signature.TimeStampUrl = new Uri("[http://timestamp.digicert.com](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"
' Add a secure timestamp from a trusted Time Stamp Authority (TSA).
' This provides cryptographic proof of the signing time.
signature.TimeStampUrl = New Uri("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")
서명 인증서가 시스템의 신뢰할 수 있는 저장소에 없는 경우, 일부 PDF 뷰어에서 경고 아이콘이 표시될 수 있습니다. 녹색 확인 표시를 받으려면 인증서를 뷰어의 신뢰할 수 있는 식별자에 추가해야 합니다.
디지털 서명에 시각적 표현을 추가하려면 어떻게 해야 합니까?
PDF에 디지털 서명이 암호학적으로 내장되어 있더라도, 페이지에 이를 시각적으로 표시해 두는 것이 종종 유용합니다. 이는 회사 로고, 손글씨 서명 이미지 또는 기타 그래픽일 수 있습니다. IronPDF를 사용하면 PdfSignature 객체에 이미지를 쉽게 추가할 수 있습니다.
파일이나 스트림에서 이미지를 불러와 PDF의 어느 페이지에든 정확하게 배치할 수 있습니다. 지원되는 이미지 형식에는 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")
이 코드는 디지털 서명에 시각적 요소를 추가하는 세 가지 동등한 방법을 보여줍니다. 디스크나 메모리에 이미지가 있든 상관없이, 서명 과정의 일환으로 이를 PDF에 쉽게 삽입할 수 있습니다. 이는 보이지 않는 암호화 보안과 눈에 보이는 문서 승인 사이의 간극을 메워줍니다.
서명 후 문서 권한을 어떻게 제어할 수 있나요?
문서에 서명할 때, 이후 허용되는 변경 사항이 있다면 이를 명시하고 싶을 수 있습니다. 예를 들어, 문서를 완전히 잠그거나 사용자가 양식 필드만 입력할 수 있도록 제한할 수 있습니다. IronPDF를 사용하면 SignaturePermissions 열거형을 사용하여 이러한 권한을 설정할 수 있습니다. 더 정교한 권한 제어를 원하시면 PDF 암호 및 권한 설정 가이드를 참조하십시오.
서명 권한 설정은 문서 수명 주기 관리의 핵심 요소입니다. 이는 서명이 적용된 후에도 귀하의 규칙에 따라 문서의 무결성이 유지되도록 보장합니다. 사용자가 허용되지 않은 작업을 수행하면 서명이 무효화됩니다.
| `SignaturePermissions` 회원 | 정의 |
|---|---|
| `NoChangesAllowed` | 어떤 종류의 변경도 허용되지 않습니다. 이 문서는 사실상 수정 불가 상태입니다. |
| `FormFillingAllowed` | 기존 양식 필드에 내용을 입력하고 서명하는 것만 허용됩니다. |
| `주석 및 양식 작성 허용` | 양식 작성, 서명, 주석 생성 또는 수정이 가능합니다. |
특정 PDF 수정본 저장 및 서명
PDF는 버전 관리 시스템과 마찬가지로 변경 내역을 저장할 수 있습니다. 이를 증분 절약이라고 합니다. PDF에 서명하면 해당 서명은 문서의 특정 버전에 적용됩니다. 이는 문서가 여러 단계의 승인 절차를 거치는 워크플로우에서 특히 중요합니다. 자세한 가이드에서 PDF 수정 내역 관리 방법에 대해 자세히 알아보세요.
다음 예제에서는 PDF를 불러와 편집한 후, 현재 버전에 서명하고 향후 변경 사항으로는 양식 작성만 허용하도록 설정합니다. 파일을 저장하기 전에 문서의 기록에 현재 상태를 반영하기 위해 SaveAsRevision를 사용합니다.
GetRevision
증분 절약을 이해하는 것은 고급 PDF 워크플로우의 핵심입니다. 단순한 뷰어는 최신 버전만 표시할 수 있지만, Adobe Acrobat과 같은 도구는 전체 수정 내역을 보여줌으로써 누가 어떤 버전에 서명했는지, 그리고 서명 사이에 어떤 변경 사항이 있었는지를 확인할 수 있습니다. IronPDF를 사용하면 이 과정을 프로그래밍 방식으로 완벽하게 제어할 수 있습니다.
높은 보안 및 규정 준수가 요구되는 복잡한 문서 워크플로를 관리하는 기업의 경우, 포괄적인 솔루션이 필요할 수 있습니다. Iron Software는 서명 및 문서 편집을 위한 IronPDF와 다양한 문서 처리 작업을 위한 기타 라이브러리를 포함하는 Iron Suite를 일회성 결제로 제공합니다.
여러 버전의 서명을 어떻게 관리하고 확인할 수 있나요?
PDF 문서에는 여러 버전에 걸쳐 여러 개의 서명이 적용될 수 있습니다. IronPDF는 이 기록을 효과적으로 관리할 수 있는 도구를 제공합니다.
- 이전 버전으로 롤백:
RollBackToRevision메서드를 사용하여 문서를 이전 상태로 되돌릴 수 있습니다. 이렇게 하면 해당 수정 이후 이루어진 모든 변경 사항과 서명이 삭제됩니다. - 모든 서명 확인:
VerifyAllSignatures메서드는 문서의 모든 개정판에 걸쳐 모든 서명의 유효성을 확인합니다. 모든 서명이 유효하고 무단 변경이 없는 경우에만SignatureStatus.Valid를 반환합니다. - 서명 제거:
RemoveSignatures메서드는 문서의 모든 개정판에서 디지털 서명을 모두 제거하여, 서명이 없는 깨끗한 버전을 생성합니다.
// 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.VerifySignatures();
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.VerifySignatures();
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");
Imports System
' 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.VerifySignatures()
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는 Watermark 또는 Stamp 기능을 사용하여 이를 수행할 수 있습니다. 더 고급 워터마킹 옵션을 원하시면, 당사의 맞춤형 워터마크 가이드를 확인해 보세요.
먼저 샘플 송장 PDF와 .png 손글씨 서명 이미지를 살펴보겠습니다.
VerifySignatures
서명을 날인하기 전의 원본 송장 PDF.
다음은 적용할 시그니처 이미지입니다:
손글씨 서명 이미지 예시.
다음 코드는 SignatureImage 속성을 사용하여 이 이미지를 PDF의 오른쪽 하단 모서리에 찍습니다.
using IronPdf.Editing;
// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");
// Create an HtmlStamp containing our signature image.
// HtmlStamp allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamp("<img src='assets/signature.png'/>")
{
// Configure the stamp's position and appearance.
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = 10, // Add some space from the edge.
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.Editing;
// Load the existing PDF document.
var pdf = PdfDocument.FromFile("invoice.pdf");
// Create an HtmlStamp containing our signature image.
// HtmlStamp allows us to position HTML content precisely on the page
var signatureStamp = new HtmlStamp("<img src='assets/signature.png'/>")
{
// Configure the stamp's position and appearance.
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = 10, // Add some space from the edge.
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.Editing
' Load the existing PDF document.
Dim pdf = PdfDocument.FromFile("invoice.pdf")
' Create an HtmlStamp containing our signature image.
' HtmlStamp allows us to position HTML content precisely on the page
Dim signatureStamp = New HtmlStamp("<img src='assets/signature.png'/>") With {
' Configure the stamp's position and appearance.
.VerticalAlignment = VerticalAlignment.Bottom,
.HorizontalAlignment = HorizontalAlignment.Right,
.Margin = 10, ' Add some space from the edge.
.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의 양식 컬렉션에 추가할 수 있습니다. 페이지 내 위치와 크기를 정밀하게 제어할 수 있습니다. 이는 여러 명의 서명이 필요한 문서나 외부 관계자로부터 서명을 수집해야 하는 경우에 특히 유용합니다.
true``RemoveSignatures
using IronPdf.Forms;
using IronSoftware.Drawing;
// 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
int pageIndex = 0; // Add to the first page (zero-indexed)
var fieldRect = new Rectangle(50, 200, 300, 100); // Position: (x, y), Size: (width, height)
// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, fieldRect);
// 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 IronPdf.Forms;
using IronSoftware.Drawing;
// 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
int pageIndex = 0; // Add to the first page (zero-indexed)
var fieldRect = new Rectangle(50, 200, 300, 100); // Position: (x, y), Size: (width, height)
// Create the SignatureFormField object.
// This creates an interactive field that users can click to sign
var signatureField = new SignatureFormField(fieldName, pageIndex, fieldRect);
// 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 IronPdf.Forms
Imports IronSoftware.Drawing
' Create a new PDF to add the signature field to.
Dim renderer As 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 Integer = 0 ' Add to the first page (zero-indexed)
Dim fieldRect As New Rectangle(50, 200, 300, 100) ' Position: (x, y), Size: (width, height)
' Create the SignatureFormField object.
' This creates an interactive field that users can click to sign
Dim signatureField As New SignatureFormField(fieldName, pageIndex, fieldRect)
' 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를 열면 클릭 가능한 필드가 표시되며, 이를 통해 자신의 디지털 ID를 사용하여 서명 절차를 완료할 수 있습니다. PDF 양식 작성에 관한 사용 안내서에서 대화형 양식 작성 및 관리에 대해 자세히 알아보실 수 있습니다.
PDF 문서에 프로그래밍 방식으로 추가된 서명 미입력 대화형 서명 필드.
검증된 서명에서 서명자 이름을 어떻게 가져올 수 있나요?
서명을 한 인증서 소유자의 일반 이름을 얻으려면 VerifiedSignature 클래스를 사용하여 SignerName 속성에 접근할 수 있습니다. 이를 구현하는 방법을 보여주는 코드 스니펫은 다음과 같습니다.
:path=/static-assets/pdf/content-code-examples/how-to/signing-find-signer-name.cs
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)
서명된 PDF 파일을 가져온 후, GetSignatures(...) 메서드를 사용하여 보고서 내의 VerifiedSignature 객체 목록을 가져오고 각 서명에 대한 SignerName을 인쇄합니다.
GetVerifiedSignatures``SignerName
이 값은 인증서의 Subject Distinguished Name(SubjectDN)에서 추출되며, CN 필드가 없는 경우 null을 반환합니다.
IronPDF를 사용한 PDF 서명의 다음 단계는 무엇입니까?
이 가이드는 IronPDF의 강력하고 유연한 PDF 서명 기능을 보여줍니다. 상세한 메타데이터가 포함된 안전한 디지털 서명을 적용하거나, 문서 수정 내역을 관리하거나, 시각적 서명을 찍거나, 대화형 양식을 생성해야 하는 경우, IronPDF는 작업을 수행할 수 있는 포괄적이고 개발자 친화적인 API를 제공합니다.
더 자세히 알아보시려면 IronPDF for .NET 라이브러리를 다운로드하고 무료 체험 라이선스를 받아 프로젝트에서 모든 기능을 테스트해 보실 수 있습니다. 주석 추가 및 양식 필드 작업 등 보다 고급 문서 조작 기법에 대해서는 당사의 포괄적인 문서와 튜토리얼을 확인해 주십시오.
다른 기능도 확인해 보시겠습니까? 여기에서 튜토리얼 페이지를 확인해 보세요: PDF 서명 및 보안 설정
자주 묻는 질문
C#에서 인증서를 사용하여 PDF에 디지털 서명을 하려면 어떻게 해야 하나요?
IronPDF를 사용하면 PdfSignature 클래스를 이용하여 단 한 줄의 코드로 PDF에 디지털 서명을 할 수 있습니다. 인증서 파일(.pfx 또는 .p12)과 암호를 사용하여 새 PdfSignature 객체를 생성한 다음 SignPdfFile() 메서드를 호출하기만 하면 됩니다. 예를 들어, 다음과 같습니다. new IronPdf.Signing.PdfSignature("certificate.pfx", "password").SignPdfFile("input.pdf"). 이렇게 하면 X509Certificate2를 사용하여 변조 방지 디지털 서명이 적용되어 문서의 진위가 보장됩니다.
지원되는 PDF 서명 유형은 무엇입니까?
IronPDF는 세 가지 주요 유형의 PDF 서명을 지원합니다. 1) 인증 및 변조 방지를 위해 X509Certificate2 인증서를 사용하는 디지털 서명, 2) 문서에 그래픽 또는 손글씨 서명 이미지를 추가하는 시각적 서명 스탬프, 3) 사용자가 PDF에 전자 서명을 할 수 있는 대화형 서명 양식 필드입니다. 각 유형은 문서 보안 및 워크플로 요구 사항에 따라 서로 다른 용도로 사용됩니다.
디지털 서명에 사용할 수 있는 인증서 형식은 무엇인가요?
IronPDF는 .pfx(개인정보 교환) 및 .p12 파일을 포함한 일반적인 디지털 인증서 형식을 지원합니다. 이러한 인증서 파일에는 디지털 서명에 필요한 공개 키와 개인 키가 모두 포함되어 있습니다. IronPDF의 PdfSignature 클래스는 모든 X509Certificate2 객체와 함께 작동할 수 있으므로 서명 인증서를 로드하고 관리하는 방식에 유연성을 제공합니다.
디지털 서명에 시각적 표현을 추가할 수 있나요?
네, IronPDF를 사용하면 디지털 서명에 시각적 요소를 추가할 수 있습니다. 암호화 서명과 함께 자필 서명 이미지, 회사 로고 또는 사용자 지정 스탬프와 같은 그래픽 표현을 포함할 수 있습니다. 이를 통해 디지털 인증서의 보안과 시각적 확인을 결합하여 서명된 문서를 안전하고 전문적으로 보이게 할 수 있습니다.
사용자가 전자 서명을 할 수 있는 대화형 서명 필드를 어떻게 만들 수 있나요?
IronPDF를 사용하면 PDF 문서에 대화형 서명 양식 필드를 추가할 수 있습니다. 이 필드를 통해 사용자는 클릭하여 서명을 그리거나 서명 이미지를 업로드하여 문서에 전자 서명을 할 수 있습니다. 이 기능은 계약서나 여러 당사자의 서명이 필요한 양식과 같이 서명 수집이 필요한 문서를 제작하는 데 매우 유용합니다.
PDF 문서에 서명하는 것이 문서의 무결성을 보장할까요?
네, IronPDF를 사용하여 X509Certificate2로 PDF에 디지털 서명을 하면 문서의 무결성을 보장하는 위변조 방지 봉인이 생성됩니다. 디지털 서명은 서명 이후 문서가 변경되지 않았음을 보장합니다. 서명 후 PDF를 수정하면 서명이 무효화되어 수신자에게 문서가 손상되었을 가능성이 있음을 알립니다.

