Digital signature is the alternative way of signing documents in era of electronic exchange of documents. Creating digital signature in PDF, without any doubt, becomes one of the most popular ways to protect PDF file from editing and tampering. This section will introduce a solution to create digital signature in PDF via a .NET PDF component.

Spire.PDF for .NET, with rich features to protect and manipulate PDF documents, allows you to keep your PDF secure by creating digital signature in PDF with C#, VB.NET. As long as the digital signature is signed, the signer's identity has been verified and your PDF document can be safe and cannot be modified.

Please download Spire.PDF for .NET and view the screenshot of this task as below picture:

Create Digital Signature

In the key code, first you are required to create one instance of Spire.Pdf.Security.PdfCertificate class with two parameters passed: a certificate file and the file password. This instance is named to be digi. After that, digi is used as a parameter of another instance in a different class: PdfSignature class. Here it is called signature. In order to sign PDF digital signature in any page, a "page" parameter is provided. Through DocumentPermission, you can restrict the PDF permission to be AllowComments, AllowFormFill and ForbidChanges.

       String pfxPath = @"..\Demo.pfx";
            PdfCertificate digi = new PdfCertificate(pfxPath, "e-iceblue");
            PdfSignature signature = new PdfSignature(doc, page, digi, "demo");
            signature.ContactInfo = "Harry";
            signature.Certificated = true;
            signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
Dim pfxPath As String = "..\Demo.pfx"
Dim digi As PdfCertificate = New PdfCertificate(pfxPath, "e-iceblue")
Dim signature As PdfSignature = New PdfSignature(doc, page, digi, "demo")
signature.ContactInfo = "Harry"
signature.Certificated = true
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill

Spire.PDF for .NET is a .NET PDF component which can secure your PDF by encrypting PDF and creating PDF digital signature. When you need to unlock PDF file, it also enables you to decrypt PDF in a fast way.

Published in Security