This tutorial shows how to digitally sign a PDF document using JSignPDF. JSignPDF is a free software which lets you digitally sign PDF documents for free. A digital signature is necessary these days. To have a digital signature over a PDF might be a bit complicated but JSignPDF is a one stop solution for this question.
At first download JSignPDF from sourceforge. Follow the simple installation instructions.
In order to get started we need a pair of private/public keys which are necessary to generate certificates. We will use the Java utility keytool.
D:\keys>keytool -genkey -dname "cn=Tom Jones, ou=JavaSoft, o=Sun, c=US" -alias business -keypass mypass -keystore mykeystore -storepass mypass -validity 180
D:\keys>keytool -export -alias business -keystore mykeystore -keypass mypass -storepass mypass -file MJ.cer
D:\keys>keytool -export -alias business -keystore mykeystore -keypass mypass -storepass mypass -file MJ.cer
This first command creates the keystore named "mykeystore" in the "working" directory, and assigns it the password "mykeystore". It generates a public/private key pair for the entity whose "distinguished name" has a common name of "Tom Jones", organizational unit of "JavaSoft", organization of "Sun" and two-letter country code of "US".
With the second command, you export the certificate and supply it to your clients. As a result you will obtain a certificate named
MJ.cer
Click Sign It and verify that the document with signature has been generated successfully:
Now try to open your document with Acrobat Reader. You will notice that the document bears a signature, however it is not recognized by an authority nor it's included in your trust list.
You can either choose to register your certificate on a trust authority (and pay a few hundreds $$) or you can simply upload your certificate and declare it as trusted.
Choose Document | Manage Trusted Identities and choose "Add contacts":
Using a batch script to sign PDFs:
If you have to sign documents as part of a process, you can use as well the JSignPdf.jar library and add the required parameters. (See JSignPdf documentation for more info about it).
Example:
java -jar JSignPdf.jar -kst JKS -ksf mykeystore -ksp mypass C:/documents/sampledoc.pdf