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


A digital signature becomes one of the most secure ways to keep PDF document safe and away from tampering. Digital signature contains encrypted information and always password protected, which helps you to protect and authenticate a PDF document. It verifies the signer signing PDF document and keeps your PDF content from forging and tampering. Talking about adding PDF signature, advanced signature algorithms like SHA family should be considered.

A cryptographic hash, also called digest, is a kind of signature for a text or a data file. SHA is used to create unique hash values from files, like Adobe PDF. Thus, determine the integrity of a particular piece of data. For all Secure Hash Algorithms, SHA-1, SHA256, and SHA512 are one of the mostly popular and strongest hash functions available to sign certificates and CRL, used by SSL certification authorities. SHA-256 and SHA-512 works the same way as SHA1 but are the successor hash functions to SHA-1.

All these robust SHA signature algorithms are supported by XsPDF .NET PDF Digital Signature SDK. By using these signature algorithms in C# applications programming, your derived applications can determine that PDF document or website’s data are not edited or tampered with.

Use Robust Signature Algorithm for PDF Signing in C#

This section introduces a simple C# class coding example and shows how to apply robust PDF signature algorithm to sign certificate for a PDF document. You may download our free trial to test more.


//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);
//Choose the target algorithm from SHA1, SHA26, SHA512
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".

More Excel tutorial