Command line tool for digital signature of PDF files

It is useful for example in Batch processes, from non Java programming languages like Php, Shell scripts, etc…

You can find it in Github

BatchPDFSign is a command line to sign PDF file with a PKCS12 certificate. You need a PKCS12 certificate. It should be a .pfx file. You need a password for the .pfx A PDF file to sign.

You can create your own self signed certificate with this following 4 commands in ubuntu. Release includes this certificate with password <12345>.

openssl genrsa -aes128 -out myself.key 2048
openssl req -new -days 365 -key myself.key -out myself.csr
openssl x509 -in myself.csr -out myself.crt -req -signkey myself.key -days 365
openssl pkcs12 -export -out myself.pfx -inkey myself.key -in myself.crt

Then you can sign a PDF file with following command line.

java -jar BatchPDFSign.jar <certificate.pfx> <password> <filetosign.pdf>

With a specific output file.

java -jar BatchPDFSign.jar <certificate.pfx> <password> <filetosign.pdf> <outputfile.pdf>

For the example included in the releases.

java -jar BatchPDFSign.jar myself.pfx 12345 test.pdf

With an output file defined.

java -jar BatchPDFSign.jar myself.pfx 12345 test.pdf test-sig.pdf

That’s all folks.

2 thoughts on “Command line tool for digital signature of PDF files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s