C# code tutorial

PDF Digital Signature PDF Creating & Inserting PDF to Image PDF Extracting PDF Processing & Editing PDF Protecting PDF Chart PDF Barcode

Popular .NET SDK


Digital signature that contains encrypted information with password protect can be stored on your PC in PKCS #12. PKCS #12 is one of the mostly used standards of Public-Key Cryptography Standards (PKCS). It has two filename extensions that are .p12 and .pfx. By using these two certificate formats to sign PDF document, the identity of the signer has been identified and your PDF file cannot be edit and forged.

PFX is an encrypted security file for a PKCS #12 file. It contains secure information, like certificates, certificate chains and private keys, to verify the signer, computer, or server, and can be opened by a password. Thus, keeps cryptographic information private and the root certificate integrity. P12 is one of the formats that most modern signing utilities use. It is an alternate extension for PFX. P12 also contains a private key for keeping encrypted information private. It helps to validate the source of transmitted information.

XsPDF .NET PDF Digital Signature SDK is a comprehensive C# programming solution for creating and adding digital signatures to PDF document. This PDF signature library supports PKCS #12 encryption (.p12 and .pfx supported) and allows you easily integrating advanced PDF digital signing features to your C# windows and web projects.

How to Add Signature to PDF in C#

The following C# class example simply illustrates how to create and add a digital signature to PDF document using PKCS #12 encryption. You may also choose from the supported signature types to authenticate and protect your PDF document.


//Load the pfx certificate file with password
PdfCertificate cert = new PdfCertificate("demo.pfx", "your-password");
PdfSigner signer = new PdfSigner("demo.pdf", cert);
//Input the signature info
signer.ContactInfo = "your contact information";            
signer.Location = "your location";           
signer.Reason = "your reason";
signer.FieldName = "XsPDF Sign";
signer.PageId = 0;
signer.Rect = new Rectangle(100, 100, 100, 50);
signer.SignatureAlgorithm = SignatureAlgorithm.SHA256;
signer.SignatureShowingType = SignatureShowingType.Description;

signer.Sign("text-sign.pdf");

Notice - If you use the free trial version of .NET PDF Digital Signature SDK, the sign field is showing "XsPDF Signer Trial Version".