Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PdfFileSignature 클래스는 PDF 파일에 서명을 추가할 수 있게 해줍니다. 입력 및 출력 PDF 파일을 사용하여 PdfFileSignature 클래스의 객체를 생성해야 합니다. 서명을 추가할 위치에 Rectangle 객체를 생성해야 하며, 서명의 모양을 설정하기 위해 PdfFileSignature 객체의 SignatureAppearance 속성을 사용하여 이미지를 지정할 수 있습니다. Aspose.Pdf.Facades는 PKCS#1, PKCS#7 및 PKCS#7Detached와 같은 다양한 서명 유형도 제공합니다. 특정 유형의 서명을 생성하려면 인증서 파일과 비밀번호를 사용하여 PKCS1, PKCS7 또는 PKCS7Detached와 같은 특정 클래스의 객체를 생성해야 합니다.
특정 서명 유형의 객체가 생성되면, PdfFileSignature 클래스의 Sign 메서드를 사용하여 PDF에 서명하고 이 클래스에 특정 서명 객체를 전달할 수 있습니다. 이 메서드에 대한 다른 속성도 지정할 수 있습니다. 마지막으로, PdfFileSignature 클래스의 Save 메서드를 사용하여 서명된 PDF를 저장해야 합니다. 다음 코드 스니펫은 PDF 파일에 서명을 추가하는 방법을 보여줍니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPdfFileSignature()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "input.pdf");
// Create a rectangle for signature location
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(10, 10, 300, 50);
// Set signature appearance
pdFileSignature.SignatureAppearance = dataDir + "aspose-logo.png";
// Create any of the three signature types
var signature = new PKCS1(dataDir + "rsa_cert.pfx", "12345"); // PKCS#1
pdFileSignature.Sign(1, "I'm document author", "test01@aspose-pdf-demo.local", "Aspose Pdf Demo, Australia", true, rect, signature);
// Save PDF document
pdFileSignature.Save(dataDir + "DigitallySign_out.pdf");
}
}
다음 코드 예제는 두 개의 서명으로 문서에 서명할 수 있는 기능을 보여줍니다. 우리의 예제에서는 첫 번째 페이지에 첫 번째 서명을, 두 번째 페이지에 두 번째 서명을 추가합니다. 필요한 페이지를 지정할 수 있습니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddTwoSignature()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "input.pdf");
// Create a rectangle for 1st signature location
System.Drawing.Rectangle rect1 = new System.Drawing.Rectangle(10, 10, 300, 50);
// Create 1st signature object
var signature1 = new Aspose.Pdf.Forms.PKCS1(dataDir + "rsa_cert.pfx", "12345"); // PKCS#1
pdFileSignature.Sign(1, "I'm document author", "test@aspose-pdf-demo.local", "Aspose Pdf Demo, Australia", true, rect1, signature1);
pdFileSignature.Save(dataDir + "DigitallySign_out.pdf");
// Sign with 2nd signature
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "DigitallySign_out.pdf");
// Create a rectangle for 2nd signature location
System.Drawing.Rectangle rect2 = new System.Drawing.Rectangle(10, 10, 300, 50);
// Create 2nd signature object
var signature2 = new Aspose.Pdf.Forms.PKCS1(dataDir + "rsa_cert.pfx", "12345"); // PKCS#1
pdFileSignature.Sign(2, "I'm document reviewer", "test02@aspose-pdf-demo.local", "Aspose Pdf Demo, Australia", true, rect2, signature2);
// Save PDF document
pdFileSignature.Save(dataDir + "DigitallySign2_out.pdf");
}
}
서명해야 하는 양식 또는 아크로폼이 있는 문서의 경우, 다음 예제를 참조하세요. 입력 및 출력 PDF 파일을 사용하여 PdfFileSignature 클래스의 객체를 생성해야 합니다. 바인딩을 위해 BindPdf를 사용하세요. 필요한 속성을 추가할 수 있는 서명을 생성하세요. 우리의 예제에서는 ‘Reason’과 ‘CustomAppearance’가 있습니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPdfFileSignatureField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "input.pdf");
// Create any of the three signature types
var signature = new Aspose.Pdf.Forms.PKCS1(dataDir + "rsa_cert.pfx", "12345")
{
Reason = "Sign as Author",
CustomAppearance = new Aspose.Pdf.Forms.SignatureCustomAppearance
{
FontSize = 6,
FontFamilyName = "Calibri"
}
}; // PKCS#1
pdFileSignature.Sign("Signature1", signature);
// Save PDF document
pdFileSignature.Save(dataDir + "DigitallySign_out.pdf");
}
}
문서에 두 개의 필드가 있는 경우, 서명하는 알고리즘은 첫 번째 예제와 유사합니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPdfFileSignatureField2()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
// Bind PDF document
pdfFileSignature.BindPdf(dataDir + "input.pdf");
// Create any of the three signature types
var signature1 = new Aspose.Pdf.Forms.PKCS1(dataDir + "rsa_cert.pfx", "12345")
{
Reason = "Sign as Author",
CustomAppearance = new Aspose.Pdf.Forms.SignatureCustomAppearance
{
FontSize = 6
}
}; // PKCS#1
pdFileSignature.Sign("Signature1", signature1);
// Save PDF document
pdFileSignature.Save(dataDir + "DigitallySign_out.pdf");
// Bind PDF document
pdFileSignature.BindPdf(dataDir + "DigitallySign_out.pdf");
// Create any of the three signature types
var signature2 = new Aspose.Pdf.Forms.PKCS1(dataDir + "rsa_cert.pfx", "12345")
{
Reason = "Sign as Reviwer",
CustomAppearance = new SignatureCustomAppearance
{
FontSize = 6
}
}; // PKCS#1
pdFileSignature.Sign("Signature2", signature2);
// Save PDF document
pdFileSignature.Save(dataDir + "DigitallySign2_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.