Search code examples
javascriptadobeacrobat

Use Javascript to add digital signature box to any pdf


So I've spent a fair amount of time searching both on stack overflow and elsewhere and usually people are trying to add a signature block and sign a pdf.

I am looking to add a signature box in the same location on the document, to any PDF. My problem, we produce a documents for approval for a client to sign, it is extremely time consuming to go into adobe dc, prepare form, add the signature box and save it. I've written all this in less time then it takes to do all that. I want to create a desktop java script that adds a signature box to any open pdf.

I'm a total novice to java but use VBA in excel regularly.

I have tried this one suggestion from (https://forums.adobe.com/thread/2342110)

    var name = "sigField";
    var type = "signature";
    var page = 0;
    var mySigRect = ;
    var sf = this.addField(name, type, page, mySigRect);

it didn't work. just an error on the last semi colon.

Any help would be wonderful!

Cheers.


Solution

  • I just tried this and it worked.

    1. you have to enter a 4-item array for mySigRect. I used mySigRect = [10,10,500,500] and I got a ridiculously sized signature box. Experiment with it.

    2. When running code in the Acrobat Javascript console (CTRL-J) you need to put all lines of code on a single line (no line breaks). Then move the cursor to immediately after the last semicolon. Then click CTRL-Enter.

    This should accomplish what you want - adding a signature box. It will not add your signature. You have to click the box to do that.