Contact us at support@legalesign.com if no relevant article exists yet.
Home > API > Using html/text in the API

Using html/text in the API

Information about using text templates

i) Fields in html/text templates
ii) Styles in html/text templates
iii) Images in html/text templates

i) Fields in html/text templates

Fields are SPAN element written into the source of your document to define where you want to put signatures and form fields for the signer(s).

The easiest way to familiarise yourself with fields is to create a template using different field types in the web interface and inspect the HTML. The attributes are:

SPAN attribute Type Description
class string must always have the value ‘field’
data-signee integer the signer to which the field applies (start from 1) - see note below
data-name string label for the field e.g. Please sign here
data-optional bool true/false - require the field to be completed by the signer
data-type string can be 'text’,'select’ or 'signature’, text is a plain text field and select is a list
data-options string if using 'select’ data-type, add the drop down options delimited with ’^’, e.g. yes^no

If you see other options in Legalesign source code you can ignore them these are added by us later.

data-type 'signature’ note: add this where you want to place a signature. If you use this data-type make sure you have at least one for each signer. If you do not use this data-type check the 'signature_placement’ document option for adding signatures automatically.

data-signee note: confusingly the signer order is zero-indexed when you POST to the document endpoint, but 1-indexed in these text fields. Thus text fields where you write 'data-signee=1’ refer to the signer with order '0’ in other parts of the API. Sorry about that.

If you want to add/edit Legalesign text/html templates in a WYSIWYG you may find it helpful to use the tinymce fields plugin at https://bitbucket.org/legalesign/tinymce_field. Contact us if you this for more help.

ii) Styles/CSS in html/text documents

Add styles in a <style> attribute at the start of the document. Use the API call '/pdf/preview/' to get PDFs rendered so you can iterate testing. Getting styles correct so that the document renders on screen and on PDF can be testing. Use tables over divs. Use discrete classes and ids. Do NOT refer to tags in your css (i.e. h1 or p or a etc). Use page-break-before/after css style to get the page breaks correct in the PDF.  Get remove headers contact us. The page margin is set in 'Doc options' on the website.

iii) Images in html/text documents

Images placed in a html/text document MUST (a) be linked from a secure HTTPS server, you should not use HTTP, (b) and they must have width and height attributes.

Back to main website
Email us at support@legalesign.com