We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Trying to digitally sign a document

I am trying to digitally sign a document using pfx file and using the below code. But the PKCS1 object is always null.

string pbxFile = “”;
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create PdfFileSignature object and bind input and output PDF files
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(dataDir + “DigitallySign.pdf”);
// Create a rectangle for signature location
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
// Set signature appearance
pdfSign.SignatureAppearance = dataDir + “aspose-logo.jpg”;
// Create any of the three signature types
PKCS1 signature = new PKCS1(pbxFile, “password”); // PKCS#1 or

pdfSign.Sign(1, “Signature Reason”, “Contact”, “Location”, true, rect, signature);
// Save output PDF file
pdfSign.Save(dataDir + “DigitallySignature_out.pdf”);


Could you please share a bit more details about the issue by sharing sample PFX file and source PDF document. We will test the scenario in our environment and address it accordingly.

PrivateKeyCert.zip (2.8 KB)

We have a old application which is using aspose 11.3 version. I am trying to add a digital signature to the pdf document. I tried to use the example code that is in aspose website, but no matter is I use PFCS1 or 7, the object is null from within. Attached is the pfx file I am using.



Would you please share the password of PFX file that you have shared.

Also, please note that it is always recommended to use latest version of the API because it contains more fixes and enhancements. In the above share code sample, please make sure to specify the filename of PFX and its password. In case the issue still persists, please share the password with us. We will test the scenario in our environment and address it accordingly.