Here are the steps to create a custom job in Qoppa PAS that clears any signatures on the document. Make sure to change the output file path below.
1. Create a custom job through Qoppa Job Creator Wizard and open the job properties to edit the code section.
2. Replace the import section with the following:
import java.io.IOException; import java.util.Vector; import java.util.logging.Level; import com.qoppa.pas.api.CustomProcess; import com.qoppa.pas.api.JobStatus; import com.qoppa.pas.api.ServerContext; import com.qoppa.pas.api.WorkingBundle; import com.qoppa.pdf.PDFException; import com.qoppa.pdf.form.SignatureField; import com.qoppa.pdfProcess.PDFDocument; |
Replace the process() method stub with the following code:
@Override public boolean process(ServerContext context, JobStatus jobStatus, WorkingBundle bundle) { // Get the PDF document from the working bundle PDFDocument pdfDoc = bundle.getPDFDocument(); // Get a list of the signature fields Vector<SignatureField> signatureFields = pdfDoc.getAcroForm().getSignatureFields(); // Loop thru all of the signature fields for (SignatureField signatureField : signatureFields) { if (signatureField.hasBeenSigned()) { // Clear the signature if it has been signed signatureField.clearSignature(); } } // Build the output complete file path *************** // TODO - This path should be modified String outputPath = "C:\\qoppa\\temp\\PAS\\remove_sigs\\output\\" + bundle.getInitialFileName(); try { // Save the PDF document pdfDoc.saveDocument(outputPath); } catch (IOException | PDFException e) { context.createLogService().log(Level.WARNING, "Unable to save document to " + outputPath, e); } return true; } |