Description
I am trying to get the original pdf from the signed pdf.
I am able to remove the signature using doc.getSignatureDictionaries().get(0).getSignedContent(signedPDF);
However, the signature field stays.
However, when I try to remove the signature fields using the following code:
PDDocument pdDoc = PDDocument.load(origPDF);
PDDocumentCatalog catalog = pdDoc.getDocumentCatalog();
PDAcroForm form = catalog.getAcroForm();
List<PDField> acroFormFields = form.getFields();
for (PDField field: acroFormFields) {
if (field.getFieldType().equalsIgnoreCase("Sig"))
The signature field is removed, but the image that was used for visible signature, somehow, magically appear. (The document that I load here is the one that has signature removed using origPDF = doc.getSignatureDictionaries().get(0).getSignedContent(signedPDF);
See the attached files:
Example.pdf (Original file)
Example_Signed.pdf (Signed File)
Example_Signed_orig.pdf (after removing the signature)
Example_Signed_final.pdf (after flattening the Example_Signed_orig.pdf)
See the stackoverflow post for more details: