Table of Contents show
Introduction
PDF files are not natively supported in Java, so to digitally sign them, you will need some special software. This tutorial demonstrates how to digitally sign PDF files using the JPedal PDF library. JPedal is the best Java PDF library for developers.
Step 1: Download JPedal
Download JPedal and add the Jar to your project
Step 2: Create a Keystore
Create a PKCS#12 keystore file which contains your private key and certificate
Step 3: Run the Signing Code
Run the following code:
PdfSigner.signPdf(
"inputFile.pdf",
"outputFile.pdf",
"keystorePassword",
"keystoreFile.p12",
"signerName",
"signerLocation",
"signingReason",
ACCESS_PERMISSION.P1
);
Step 4: Set Access Permissions
You can use different access permission levels to specify how the document can be modified. P1 means no changes are permitted. You can find the other levels on our support site.
Learn more
We’ve been working with the PDF file format for more than 20 years and can help you understand the PDF format.