Below is sample Java code showing how to lock a PDF document when applying a digital signature to it using jPDFSecure, Qoppa’s Java PDF Security SDK.

 
// load PDF document into jPDFSecure
PDFSecure pdf = new PDFSecure("c:/test/test01.pdf", null);
 
// add a signature field
SignatureField signField = pdf.addSignatureField(0, "sign here", new Rectangle(72, 72, 144, 72)); 
 
// Create signature information
SigningInformation signInfo = new SigningInformation("c:/test/test.pfx", "pass123", "alias01", "pass123");
 
// set the flag to lock the document
signInfo.setLockDocument(true); 
 
// sign the PDF
pdf.signDocument(signField, signInfo);
 
// save the signed PDF
pdf.saveDocument("c:/test/test01-signed.pdf");

This will set the “P” entry in the signature field lock dictionary to 1 and the “Action” entry to “All”, meaning all fields will be locked.

When the signature lock is present there are 4 permissions that are being restricted / disabled in addition to the 2 you get with an unlocked signature (Document Assembly & Changing the Document): Commenting, Filling of Form Fields, Signing, Creation of Template Page.

Permissions on Locked Digital Signatures
Additional Permissions on a PDF Document with Locked Signature