public void SignPdfDocument()
{
//ExStart
//ExFor:PdfSaveOptions
//ExFor:PdfDigitalSignatureDetails
//ExFor:PdfSaveOptions.DigitalSignatureDetails
//ExFor:PdfDigitalSignatureDetails.#ctor(X509Certificate2, String, String, DateTime)
//ExId:SignPDFDocument
//ExSummary:Shows how to sign a generated PDF document using Aspose.Words.
// Create a simple document from scratch.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Test Signed PDF.");
// Load the certificate from disk.
// The other constructor overloads can be used to load certificates from different locations.
CertificateHolder ch = CertificateHolder.Create(MyDir + "certificate.pfx", "123456");
// Pass the certificate and details to the save options class to sign with.
PdfSaveOptions options = new PdfSaveOptions();
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(ch, "Test Signing", "Aspose Office", DateTime.Now);
// Save the document as PDF with the digital signature set.
doc.Save(MyDir + "Document.Signed Out.pdf", options);
//ExEnd
}