Aspose::Words::Saving::PdfDigitalSignatureDetails class

PdfDigitalSignatureDetails class

Contains details for signing a PDF document with a digital signature.

class PdfDigitalSignatureDetails : public System::Object

Methods

MethodDescription
get_CertificateHolder() constReturns the certificate holder object that contains the certificate was used to sign the document.
get_HashAlgorithm() constGets or sets the hash algorithm.
get_Location() constGets or sets the location of the signing.
get_Reason() constGets or sets the reason for the signing.
get_SignatureDate() constGets or sets the date of the signing.
get_TimestampSettings() constGets or sets the digital signature timestamp settings.
GetType() const override
Is(const System::TypeInfo&) const override
PdfDigitalSignatureDetails()Initializes an instance of this class.
PdfDigitalSignatureDetails(const System::SharedPtr<Aspose::Words::DigitalSignatures::CertificateHolder>&, const System::String&, const System::String&, System::DateTime)Initializes an instance of this class.
set_CertificateHolder(const System::SharedPtr<Aspose::Words::DigitalSignatures::CertificateHolder>&)Returns the certificate holder object that contains the certificate was used to sign the document.
set_HashAlgorithm(Aspose::Words::Saving::PdfDigitalSignatureHashAlgorithm)Setter for Aspose::Words::Saving::PdfDigitalSignatureDetails::get_HashAlgorithm.
set_Location(const System::String&)Setter for Aspose::Words::Saving::PdfDigitalSignatureDetails::get_Location.
set_Reason(const System::String&)Setter for Aspose::Words::Saving::PdfDigitalSignatureDetails::get_Reason.
set_SignatureDate(System::DateTime)Setter for Aspose::Words::Saving::PdfDigitalSignatureDetails::get_SignatureDate.
set_TimestampSettings(const System::SharedPtr<Aspose::Words::Saving::PdfDigitalSignatureTimestampSettings>&)Setter for Aspose::Words::Saving::PdfDigitalSignatureDetails::get_TimestampSettings.
static Type()

Remarks

At the moment digitally signing PDF documents is only available on .NET 2.0 or higher.

To digitally sign a PDF document when it is created by Aspose.Words, set the DigitalSignatureDetails property to a valid PdfDigitalSignatureDetails object and then save the document in the PDF format passing the PdfSaveOptions as a parameter into the Save() method.

Aspose.Words creates a PKCS#7 signature over the whole PDF document and uses the “Adobe.PPKMS” filter and “adbe.pkcs7.sha1” subfilter when creating a digital signature.

Examples

Shows how to sign a generated PDF document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Contents of signed PDF.");

SharedPtr<CertificateHolder> certificateHolder = CertificateHolder::Create(MyDir + u"morzal.pfx", u"aw");

// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
auto options = MakeObject<PdfSaveOptions>();

// Configure the "DigitalSignatureDetails" object of the "SaveOptions" object to
// digitally sign the document as we render it with the "Save" method.
System::DateTime signingTime = System::DateTime::get_Now();
options->set_DigitalSignatureDetails(MakeObject<PdfDigitalSignatureDetails>(certificateHolder, u"Test Signing", u"My Office", signingTime));
options->get_DigitalSignatureDetails()->set_HashAlgorithm(PdfDigitalSignatureHashAlgorithm::Sha256);

ASSERT_EQ(u"Test Signing", options->get_DigitalSignatureDetails()->get_Reason());
ASSERT_EQ(u"My Office", options->get_DigitalSignatureDetails()->get_Location());
ASSERT_EQ(signingTime.ToUniversalTime(), options->get_DigitalSignatureDetails()->get_SignatureDate().ToUniversalTime());

doc->Save(ArtifactsDir + u"PdfSaveOptions.PdfDigitalSignature.pdf", options);

See Also