3

I am having an issue with SignHereTabs appearing out of place in a DocuSign document.

I use ITextSharp to take a PDF forms template with many fields, I set data into the fields leaving 2 signature fields named appropriately, I then use GetFieldPositions to obtain the location of the signature field and I locate the SignHereTab at these co-ordinates. However, in the final document from DocuSign, the tab is in the wrong place.

Here is my code to read the AcroField positions

var pdfReader = new PdfReader(pdfFilename);
var fieldPositions =pdfReader.AcroFields.GetFieldPositions("Signature");

var PageNumber = (int)fieldPositions[0];
var XPosition = (int)Math.Ceiling(fieldPositions[1]);
var YPosition = (int)(pageHeight - (fieldPositions[2] + fieldPositions[4])/2);

These are then added in the right place of the XML.

Example image is here http://i60.tinypic.com/sboizr.png

I'm unsure whether this is a problem with PDF, ITextSharp or DocuSign.

  • How are those positions documented for DocuSign? iText(Sharp) returns coordinates as defined by the media box. Maybe Docusign has a different coordinate system. – mkl Sep 26 '14 at 11:57
  • 1
    I couldn't find anything specific in the docusign documentation to say what the units are or the coordinate system. – Adam Godley Sep 26 '14 at 12:00
  • 1
    If I interpret the `xPosition` and `yPosition` entries in https://www.docusign.co.uk/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Tabs/Sign%20Here%20Tab.htm correctly, they are your `SignHereTabs` position. That page says: *in a coordinate space that has left **top** corner of the document as origin.* Most likely their y coordinates *increase downwards*. iText(Sharp), on the other hand, uses the coordinate system from the media box and crop box, where the origin may be anywhere (very often in the **bottom** left corner) and the y coordinates *increase upwards*. You must transform. – mkl Sep 26 '14 at 13:05
  • Agreed, which is already in the code. Note that I take the average of the top and bottom of the field and subtract that from page height. – Adam Godley Sep 27 '14 at 15:20
  • Maybe the point of the field you use as anchor is a different one than the one used by DocuSign. I don't use DocuSign, so I don't know but can only guess. If the DocuSign support cannot or does not want to help, you have to experiment. – mkl Sep 27 '14 at 15:58

1 Answers1

0

DocuSign's coordinate system is just as mkl has suggested, the origin (0,0) is top left of the document and the x-value increases as you move right and the y-value increases as you move down. I've never used iTextSharp so I do not know how it's coordinate system works, but you should be able to transform your coordinate space into what's needed.

It would help if you showed the JSON request body you are sending out to DocuSign's API. Without seeing that, the only other thing I can add here is that DocuSign gives you two different ways of specifying position - Absolute Positioning or Relative Positioning. Additionally, the default unit of measurement is Pixels.

Having said that, if you were to use Absolute positioning when placing a DocuSign signHere tab your (partial) JSON might look like this:

"tabs": {
    "signHereTabs": [
        {
            "xPosition": "100",
            "yPosition": "100",
            "documentId": "1",
            "pageNumber": "1"
        }
    ]
}

This would indicate to place one signHere tab 100 pixels to the right and 100 pixels down from the top left of page 1 of the document. On the other hand, if you wanted to use Relative or Anchor Based positioning, which allows you to place DocuSign tabs based on actual document content, your request might look something like:

"tabs": {
    "signHereTabs": [
        {
            "anchorString": "Please Sign Here:",
            "anchorXOffset": "1",
            "anchorYOffset": "0",
            "anchorIgnoreIfNotPresent": "false",
            "anchorUnits": "inches"
        }
    ]
}

The above JSON would in turn place signature tabs anywhere in the document where it found the text "Please Sign Here:", and would place the tab exactly 1-inch to the right of that text and at the same height (since yOffset is 0). Accepted units of measurement are pixels (default), cms, mms, and inches.

More on DocuSign tab positioning can be found here

Ergin
  • 9,254
  • 1
  • 19
  • 28