Check if Signature Fields are signed

WebViewer Version: 11.4.0

Please describe your issue and provide steps to reproduce it:

I am opening a PDF file with various form fields, including two signature fields, into the Apryse Webviewer. I am opening the Webviewer in a Modal, with a customized “Close” Button. I added an EventListener on that Close button to trigger saving the document and closing the page:

this.pageButtonRef.nativeElement.addEventListener(‘click’, async () => {
const doc = documentViewer.getDocument();
const xfdfString = await annotationManager.exportAnnotations();
const options = { xfdfString, flatten: this.signatureAdded };
const data = await doc.getFileData(options);
const arr = new Uint8Array(data);
this.finalBlob = new Blob([arr], { type: ‘application/pdf’ });
this.closePage(this.finalBlob);
});

I want to check wether the two Signature Fields have been signed. And if so, set signatureAdded to true.
The fields have the fieldnames “Signature1” and “Signature2”, but I already tried existing solutions in this forum and couldn’t get it to work.
Checking getValue or value on the fields doesn’t return anything helpful and “isModified” returns false, even if the fields are signed.

How can I check wether the fields have been signed?

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems like you’re trying to determine if specific signature fields in a PDF document have been signed using Apryse’s WebViewer. When dealing with signature fields, checking the isModified property might not suffice for detecting if a signature has been applied. Instead, you’ll need to verify the presence of a signature within those fields by examining the annotations linked to them.

Some things you can try:

  • Retrieve the signature fields using the getField method to access their properties.

  • Use the getValue method on each signature field to check if a signature is present.

  • Inspect the annotations associated with each signature field to determine if they contain signature data.

  • Set the signatureAdded flag to true if both fields are signed.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Hello Marvin,

Thank you for contacting WebViewer Forums.

We can check if the field is signed using the areRequiredFieldsFilled() API.

More information can be found here: Apryse WebViewer Class: FieldManager

Regards,
Luke

1 Like

I tried setting the signature fields to “required” by doing this, as suggested in the docs:

annotations.forEach(function(annot) {
if (annot instanceof Annotations.SignatureWidgetAnnotation) {
annot.fieldFlags.set(WidgetFlags.REQUIRED, true);
}
});

But then it sets one of the two fields to required, the second signature field is completely gone and the console gives out errors:

What am I doing wrong?

1 Like

Update:

I edited the PDF so the fields are already marked as “required” when opening the file, so I don’t have to set the flag programmatically.

But now, when I sign the fields, fieldManager.areRequiredFieldsFilled() still gives back “false”.

Bildschirmfoto_5-5-2025_134034_localhost

It seems like even though I sign the signature fields, the field itself doesn’t have a value added to it.
Why and what do I have to do different?

1 Like

Hello Marvin,

Thank you for your reply.

If you can provide a sample PDF with the forms and signatures in-place, I can take a closer look at the annotations. Thank you.

Regards,
Luke

1 Like

Hello Luke,

I can’t upload the original file because it has confidential info of our business, but I can upload a sample file with the exact signature fields of the original PDF.

Testdokument1.pdf (17.7 KB)

Hope that helps. Thank you!

1 Like

Hello Marvin,

There seems to be an ongoing investigation with this API currently as the default signing mode has changed to appearance and is currently not working as expected.

As a temporary workaround, please change the signing mode to Annotation, sign the fields and then the areRequiredFieldsFilled() API should be working. For example:

const tool = instance.Core.documentViewer.getTool('AnnotationCreateSignature');
tool.setSigningMode(instance.Core.Tools.SignatureCreateTool.SigningModes.ANNOTATION);

Regards,
Luke

1 Like

Thanks for the quick reply.

When I try the code you posted, I get following error on setSigningMode:

“TS2339: Property setSigningMode does not exist on type Tool”

I get this kind of error for a lot of Apryse’s methods and I don’t know why. Maybe it has something to do with me using TypeScript instead of plain JavaScript?

Hello Marvin,

These typescript warnings can be safely ignored and the methods should be working as expected. If there is an error that seems to be interfering, please submit a bug report to our support portal and we will be able to assist you further.

Regards,
Luke

Hello Luke,

when I ignore the error and try to start the application, the compile fails:

A workaround is writing it like this:

tool[“setSigningMode”]

That solution worked now, thanks.

EDIT:

@luke.dam I have another issue with making the document readonly after saving. Should I open a new thread for that?

Hello Marvin,

Glad it worked out. Please open a new thread or support ticket for any further questions. Thank you!

Regards,
Luke

1 Like