Q: Is it possible to change the workflow of the signing process in jPDFNotes?

A: Yes, you can customize the signature process.  What you are seeing right now is the default implementation of signing a field, which works from a file and prompts the end user to save the file right after signing.  However, you can customize this to do the whole process programmatically, or somewhere in between.

In the default implementation of jPDFNotes, when a signature field is clicked, the following method gets called:

PDFNotesBean.signDocument(SignatureField signField);

This method performs the following steps:

  • Prompts the end user for a PKCS#12 file (.pfx or .p12) and its password.
  • Opens the KeyStore file into a Java Keystore and gets the list of digital IDs in the file
  • Shows the IDs to the end user to have them pick one, as well as text fields to enter signature information, such as signing reason
  • Prompts the end user for an output file
  • Creates a SigningInformation object that holds all this information and then calls the following method:

PDFNotesBean.signDocument(SignDocument(SignatureField signField, SigningInformation signInfo, File outputFile);

This second method then applies the signature to the document and saves the file.  In saving, the method will call the registered IPDFSaver object, which defaults to saving to a file, but when running on the web, will save back to the web server.

To customize this behavior, you will first need to create an object that extends PDFNotesBean (call it MyNotesBean) and then override one or both of these methods.  For instance, if you wish to have the end users use a smart token, then you will need to override the first method, and in your implementation you can prompt the end user to insert the smart token, then create a Keystore and SigningInformation from the keys in the smart token, and then call the second method to handle the saving.