Pkcs7Signer(String, String, HashAlgorithmType) Constructor
SECURITY-RELATED CONSIDERATIONS
Using weak or outdated hash algorithms (such as SHA-1) may allow threat actors to manipulate or predict hash values. Use modern, secure alternatives (such as SHA-256 or stronger).
Initializes a new instance of the Pkcs7Signer class with specified settings.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v25.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
Declaration
Parameters
| Name | Type | Description |
|---|---|---|
| fileName | String | A path to a signature certificate file (.pfx file format). |
| password | String | A password for a certificate. |
| hashAlgorithm | HashAlgorithmType | A signature’s hash algorithm. |
Example
The following code snippet creates and signs a new signature form field:
//Load a document to be signed
using (var signer = new PdfDocumentSigner("SignedDocument.pdf"))
{
//Specify the name and location of the signature field
var description = new PdfSignatureFieldInfo(1);
description.Name = "SignatureField";
description.SignatureBounds = new PdfRectangle(10, 10, 150, 150);
//Create a PKCS#7 signature
Pkcs7Signer signature = new Pkcs7Signer("Signing Documents//testcert.pfx", "123", HashAlgorithmType.SHA256);
//Apply the signature to a new form field
var signatureBuilder = new PdfSignatureBuilder(signature, description);
//Specify the signature's image and signer information
signatureBuilder.SetImageData(System.IO.File.ReadAllBytes("Signing Documents//Signature.jpg"));
signatureBuilder.Location = "USA";
signatureBuilder.Name = "Jane Cooper";
//Sign and save the document
signer.SaveDocument("out2.pdf", signatureBuilder);
}
See Also