Restoring the widgets annot still shows "Sign here" for stamps but not for freehand

PDF.js Express Version

Detailed description of issue
When I restore (pulling it back from the DB) the annot to the SignatureWidgetAnnotation, the widget still shows a “sign here” for stamp but not for freehand.

Expected behaviour
Since the widget now have an annot, I would expect not to see the “Sign here”

Does your issue happen with every document, or just one?
All documents

Link to document
{Provide a link to the document in question if possible}

Code snippet
The code I’m using to restore.

if (fieldAnnot.type === “Sig”) {
.then((impAnnot) => {
widgetAnnot.annot = impAnnot[0];
//widgetAnnot.value = impAnnot[0];
} else {
fieldAnnot.value = dbField[0].answer;

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


I’m any not be setting the annot of the signature properly to the widget.
Currently I’m doing
WidgetAnnot.annot = annotation.

You may not be able to set the .annot property directly.
It also looks as if the annotation is attached to the widget by position if there is not annotation set.

Hey there,

I will investigate shortly. Ill get back to you soon with any additional info.


Hey there,

I actually cannot reproduce this issue with the standard signature flow.

How are you exporting the XFDF? Is the XFDF you are importing the same XFDF that was exported from the document?

Im testing by doing the following flow:

  1. Open a document with a signature field
  2. Sign the field by clicking “sign here” and adding a signature
  3. Exporting the XFDF and saving it somewhere
  4. Reopen the original document
  5. Import the previously saved XFDF

When I reimport that XFDF, the “Sign here” button goes away as expected.

I do not need to do any of the WidgetAnnot.annot = annotation stuff to make this work.


Logan, thank-you for looking into this.
In a single signature it all works fine. My use case is a bit different.
I generate two signature fields on top of each other. (Each signature is for a different team/company. The plan is to turn them on/off depending on what company is selected for viewing.)
I export the xfdf and store into the database, this looks fine and as expended with two fields, two widgets and two field for the values.

I sign each of the signature fields by toggling on/off the team/company. I can see each signature for each company, all is working fine. I’m storing the signature (free hand annot, or stamp) into the DB by exporting the xfdf again (the xfdf now includes the fields, widgets, field values and now the annotation free hand signature) I parse the xfdf and select and store the annot tag (signature freehand annot).

The problem happens when I restore the signature into the field. The restore process happens on document is loaded event and I first restore/import the xfdf with the fields. For each signature field I import the freehand annotation. When I do this, it looks as if the annotation is automatically associated to the field via position My problem is that I have two field at the same location and they end-up getting the same annotation automatically for each signature field.

I was hoping to use the WidgetAnnot.annot to assign the correct annotation to the field, but it is not working for me.

I know that I may be mixing two different things here (sign here and annotation association) sorry…

Much appreciate your help!!!

Hey there!

Thank you for the explanation. So at the end of the day you have two signature fields on top of each other, and you want to be able to associate a single annotation with one of the signatures.

This use case is a bit complex so I’m not sure if it will be possible, because yes you are correct, signatures are associated via position.

Let me chat with my team and see if we can find a solution.


Hey there,

My team says this is doable by using our “custom data” feature, however this means the feature would not work as expected in other PDF viewers. Would this be an issue? If not I can send you a code snippet with a solution.

Let me know,


Hi Logan, I the short term, this would not be an issue since the viewing will be done on our site with this viewer. Long term we plan on sending the documents out for signature. Even in that case this would not be an issue since we would prepare the documents with only one signature at a position.

Please do forward the code snippet.

Thank-you, your support has ben fantastic!

Hi there!

So this is actually a lot harder than we expected. The PDF spec doesn’t actually have a great way to associate annotations with the “Sign here” elements, which is why it is just position based right now.

We were able to make it work - but its quite a bit of ugly code :frowning: So instead, would you be willing to try out this build for us? We made some changes internally that should hopefully fix your issue without making any changes.

If you could download this build, and replace the core folder in your project with the contents of this zip, and let us know if the new files fix your issue, that would be amazing.

If that doesn’t work then i’ll send you the long ugly code you can use until we find a better solution.

Find the custom build below. (2.7 MB)

Thank you!

Thanks Logan, I will try out the fix!
I will not have time to it till early next week, but will let you know how it goes.

Thank-you for the support!!!

Hello Logan,
I tried to put in the new by replacing it. I got some errors when I try to load a document into the pdf viewer.

This is what my file structure looks like, you can see I renamed the old core and using the new core

I’m using React front end, python with django (backend) with postgres DB.
Maybe I did something wrong? I just simply replace the core dir with the one you provided.


Which version of Express are you using? The build I sent is compatible with 8.0+.


I’m using 8.0.1

Do you see any 404s in network tab? Looks like assets are not getting loaded correctly

Here is my network tab. There are no 404 error. I’m back on this, so my responses should be much faster.

1 Like