-->

How to Specify Text Box to Sign on PDF via API/SDK

2019-06-14 01:31发布

问题:

I have a white-text on a white-background text box on a PDF. The text in that text box is set to "<signature>". This is the area on the PDF that I want a signer's signature to go.

Please note, this is not a TEXT FIELD, but is a TEXT BOX. They're different things in Adobe PDF. For one thing, text boxes only have text and don't have actual field names like fields do.

I don't want to specific X and Y coordinates of this textbox. I don't want to use a DocuSign template. I do want to use our pre-defined text box. I do want to define the signature area entirely using the API/SDK, associating it to my text box.

This is what I've tried:

I'm using the eSign model from the SDK. I instantiated a new DocuSign.eSign.Model.SignHere object. Do I need to associate that sign here tab somehow to my text box on the PDF? I've tried setting each of the properties seperately (like below), but did not get the result I expected. Again, I want to associate a DocuSign.eSign.Model.SignHere tab with a pre-defined textbox on my PDF called.

var SignHereTab = new DocuSign.eSign.Model.SignHere();
SignHereTab.TabId = "<signature>";
SignHereTab.Name = "<signature>";
SignHereTab.AnchorCaseSensitive = "<signature>";
SignHereTab.CustomTabId = "<signature>";

Or, am I going about this all wrong? If I can't do this with a TEXT BOX, can I do it with TEXT FIELD? If it's better to use a FIELD, what code do I use to associate a sign here tab with a field? Again, I'd rather not use X/Y or Templates.

回答1:

Do I understand correctly that this is what you want to accomplish?

  • Use the API to create an Envelope, with the PDF you specify as the document
  • Have a SignHere tab automatically placed in the document based on where the string <signature> appears in the PDF

If that's the case, then you'll want to use what DocuSign refers to as anchor text -- this is a string that exists in the document as normal text (i.e.,, not within a text box, but rather, as normal text on the page). The "Get the Document to be Signed" section of this page provides a description of how to use anchor text (and even provides a sample doc that contains anchor text). An excerpt from that page:

Open Mutual_NDA.pdf in a PDF viewer. Search for the strings “signer1name”, “signer1sig”, and “signer1date”. You’ll notice that the search matches but that the text is not visible. These strings are regular text in the document. Their text color has been set to white, so they can’t be see in the document. But DocuSign can find them, and use them as anchor text to place the tabs (the signature, name, and date fields).

So, simply add the text string <signature> as white text (on white background) within your PDF. Then when specifying the SignHere tab in the "Create Envelope" API request, set the following properties for that tab:

"recipients": {
    "signers": [
        {
            "roleName": "Signer1",
            "recipientId": "1",
            "name": "John Doe",
            "email": "johnDoe@test.com",
            "tabs": {
                "signHereTabs": [
                    {
                        "anchorString": "<signature>",
                        "anchorIgnoreIfNotPresent": true,
                        "documentId": "1", 
                        "optional": false, 
                        "tabLabel": "Signature"
                    }
                ]
            }
        }
    ]
}

When used within a "Create Envelope" request (POST https://{{env}}.docusign.net/restapi//v2/accounts/{{accountId}}/envelopes), the JSON above will result in a (required) SignHere tab being automatically placed for recipient John Doe anywhere that the string <signature> appears in the document.

(I'm not very familiar with the node SDK, but I imagine that knowing what properties need to be set will get you going in the right direction.)


UPDATE #1


If it's important that the signature appear inside a textbox on the PDF, you can still accomplish this using anchor text. For example, simply place the anchor text string (ex: ) in the PDF just below the textbox where you want the signature tag to appear, the specify the anchorYOffset property and the anchorUnits property to tell DocuSign where you want the signature tab to appear relative to the position of the anchor string. In that example, here's the structure of the signature tab in the API request:

"signHereTabs": [
    {
        "anchorString": "<signature>",
        "anchorXOffset": "0", 
        "anchorYOffset": "-10",
        "anchorUnits": "pixels",
        "anchorIgnoreIfNotPresent": true,
        "documentId": "1", 
        "optional": false, 
        "tabLabel": "Signature"
    }
]

Finally (for your reference), here's the full list of the tab properties related to anchor strings:



回答2:

I'm not sure you'll be able to do this using a text box instead of text field. See this page on the REST API guide:


Document Parameters


Only the FieldTypes and FieldProperties listed below are extrapolated from the forms:

FieldTypes that are extrapolated are: CheckBox, DateTime, ListBox, Numeric, Radio, Text, Signature, and Password.
FieldProperties that are extrapolated are: ReadOnly, Required, MaxLength, Positions, and Initial Data.

There's an example of how to do the transform in the Dev Center website (you need to use composite templates) but as mentioned I think you need to use text fields for it to work. See the Transform PDF Fields section:

Transform PDF Fields



标签: docusignapi