Legacy notice!

iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments.
Check related iText 7 content!

The Digital Signatures for PDF documents eBook has been one of our most popular downloads since it was written. Although many of the principles and concepts remain the same, iText itself has changed a great deal over the years.

The code snippets included in the eBook were accompanied by complete examples which we made available on our website. As these examples were originally written for iText 5, they have been completely updated and rewritten for the latest versions of iText 7. This meant significant changes in some cases, and some examples were no longer applicable to iText 7.

This addendum links to pages with updated Java and .NET (C#) examples for each chapter of the eBook, and the table below notes the name of the example and which chapter the code example corresponds to:

Example NameDescription and Notes
Chapter 1Understanding the concept of digital signatures
DigestDefaultAn example showing how to use the MessageDigest class
DigestBCAn example demonstrating the use of the Bouncy Castle library
EncryptDecryptAn example of a simple class to encrypt and decrypt messages


Chapter 2PDF and digital signatures
SignHelloWorldA simple example of adding a visible signature to a document
SignHelloWorldWithTempFileSigning a document using a temporary file to avoid OutOfMemoryExceptions with large PDFs
SignEmptyFieldSigning an empty text field with iText
CreateEmptyFieldCreating an empty text field with iText
CustomAppearanceCreating a custom appearance for the signature by adding a grey background
SignatureAppearanceCreating custom text, custom fonts and using right-to-left writing in a signature
SignatureAppearancesAdding a custom image
SignatureMetadataAdding metadata to the signature dictionary
SignatureTypesOrdinary (approval) and Certification (author) signatures
SequentialSignaturesSequential signatures in PDFs
SignatureWorkflowAn example where multiple signatures are required
LockFieldsLocking fields and documents after signing


Chapter 3Certificate Authorities, certificate revocation and time stamping
SignWithCAcertSigning a document with a PKCS12 file from the CAcert Certificate Authority
GetCrlUrlGetting the Certificate Revocation List (CRL) URLs from a certificate chain
SignWithCRLDefaultImpUsing the default CrlClient implementation
SignWithCRLOnlineGetting the CRL online
SignWithCRLOfflineCreating a CrlClient using an offline copy of the CRL
GetOcspUrlFetching the Online Certificate Status Protocol (OCSP) URL from a certificate
SignWithOCSPSigning a document with the OCSP
GetTsaUrlExtracting a Time Stamping Authority (TSA) URL from a certificate
SignWithTSASigning a document with TSAClientBouncyCastle, an implementation of TSAClient
SignWithTSAEventAdding an event to a TSAClientBouncyCastle instance
SignWithTokenSigning a document with a USB token using Microsoft CryptoAPI (MSCAPI) - currently only available for Java
SignWithEstimatedSizeEstimating the size in bytes of the signature content


Chapter 4Creating signatures externally
SignWithPKCS11HSMSigning a document with PKCS#11 using a Hardware Security Module (HSM) - currently only available for Java
SignWithPKCS11USBSigning a document with PKCS#11 using a USB token - currently only available for Java
SignWithPKCS11SCSigning a document with PKCS#11 using a BEID - currently only available for Java
ClientServerSigningSigning a document on the client using a signature created on the server
ServerClientSigningSigning a document on the server using a signature created on the client
DeferredSigningSigning a document by creating a blank signature container, creating a signature appearance on the server and getting a hash to send to the client (deferred signing)


Chapter 5Validation of signed documents
SignatureIntegrityChecking the validity of a signature
SignatureInfoRetrieving information from a signature
CertificateValidationValidating the certificates of a signature