Here is the command line to create a pfx file with the Java keytool. This assumes that you have jdk 1.7.0_79 installed under your C:\Program Files folder.

"C:\Program Files\Java\jdk1.7.0_79\bin\keytool" -genkeypair -keystore signature.pfx -storepass mypassword -storetype pkcs12 -alias myalias -dname "cn=John Smith, ou=Google, o=Google, c=US"
Sample command prompt to create a signature pdfx file
Sample command to create a signature pfx file shown in command prompt window

Using the signature.pfx file generated above, you can add a digital signature to a PDF using Qoppa’s jPDFSecure with the sample Java code below:

// Load the document
 PDFSecure pdfDoc = new PDFSecure ("C:\\Users\\MyUserName\\input.pdf", null);
 
// Load the keystore that contains the digital id to use in signing
FileInputStream pkcs12Stream = new FileInputStream ("C:\\Users\\MyUserName\\signature.pfx");
KeyStore store = KeyStore.getInstance("PKCS12");
store.load(pkcs12Stream, "mypassword".toCharArray());
pkcs12Stream.close();
 
// Create signing information
 SigningInformation signInfo = new SigningInformation (store, "myalias", "mypassword");
// Create signature field on the first page
Rectangle2D signBounds = new Rectangle2D.Double (36, 36, 144, 48);
SignatureField signField = pdfDoc.addSignatureField(0, "signature", signBounds);
 
// Apply digital signature
pdfDoc.signDocument(signField, signInfo);
 
// Save the document
pdfDoc.saveDocument ("C:\\Users\\MyUserName\\output.pdf");