I was performing signing using the iText7 library. I tried signing one of the signature fields available on the document but after the signing, it still shows that field is unsigned. The following is the code snippet that I'm using for signing.
String fieldName = "signature1";
PdfAcroForm pdfAcroForm = PdfAcroForm.getAcroForm(pdfDocument, false);
PdfArray pdfArray = pdfAcroForm.getField(fieldName).getWidgets().get(0).getRectangle();
Rectangle rect = pdfArray.toRectangle();
PdfSignatureAppearance appearance = pdfSigner.getSignatureAppearance().setReason("Test")
.setLocation("Test").setReuseAppearance(false);
appearance.setPageRect(rect).setPageNumber(1);
IExternalSignature pks =
new PrivateKeySignature(pk, DigestAlgorithms.SHA256, provider.getName());
pdfSigner.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, CryptoStandard.CMS);
Updated
For the following pdf, I'm not getting the signature visibility on the document despite signing the field as mentioned in the response; however, working for the above earlier shared pdf.
pdfSigner.setFieldName(fieldName);

