Text

Inserting and modifying text

A common use of Documotor is inserting textual data into templates. With these functions you can add text that matches the formatting of the template, or define your own formatting. You can also add hyperlinks to portions of text.

Slide bindingDescription
FieldInsert text.
FormatSet background and text colors.
HyperlinkAdd a hyperlink to a portion of text.
RichHtmlTextInsert html-formatted text into a document.

Field

{ "BindingType": "Field", "BindingKey": "TextToInsert" }

Replaces the content in the content control with the string or number in the data. The content is removed if the path doesn’t exist or is null.

Parameters

string BindingType

Always "Field" to invoke the Field binding.

JSON path TextToInsert

A path to a string or number to insert inside of the content control.

Format

{"BindingType": "Format", "BindingKey": "FormatPath"}

Sets the formatting of the area inside the content control.

Parameters

JSON path BindingType

Always "Format" to invoke the Format binding.

JSON path FormatPath

A path pointing to an object containing some of the following properties:

{
  "ForegroundColor": "FF7A00",             // can be R,G,B or HEX
  "BackgroundColor": "0,122,255",          // can be R,G,B or HEX
  "Style": "Heading 1",
  "FontSize": "14.5"                         // number or string
}

"ForegroundColor" sets the text color, "BackgroundColor" sets the background color, and "Style" applies a specified Word style to the text. "FontSize" sets font size, supporting integers and 0.5 increments. Works with both default and custom styles.

Hyperlink

{ "BindingType": "Hyperlink", "BindingKey": "URLPath", "BindingAltText": "AltTextPath" }

Create a hyperlink in a Word template. The created hyperlink can have a URL and tooltip text based on transformed data.

Parameters

string BindingType

Always "Hyperlink" to invoke the RichHtmlText binding.

string URLPath

A path to a string containing the URL.

string AltTextPath [optional]

A path to a string to be used as a tooltip for the hyperlink.

RichHtmlText

{ "BindingType": "RichHtmlText", "BindingKey": "RichTextPath" }

Insert html-formatted text into the document. The html doesn’t need to be a full document, but the paragraphs do need to be tagged. For example, the string "This is a text with <b>bold</b> text" is not a valid format, but "<p>This is a text with <b>bold</b> text.</p>" is valid.

Parameters

string BindingType

Always "RichHtmlText" to invoke the RichHtmlText binding.

string KeepDestStyle

If true (case-insensitive), keep the paragraph style settings from the destination document. All other strings are considered false, and then the paragraph style settings defined in the HTML are kept. The paragraph settings include spacing, alignment, paragraph color, etc. Inside Word, they are managed in the paragraph toolbar.

The paragraph toolbar.

The paragraph toolbar.

string RichTextPath

A path to an html-formatted string.

Remarks

Read HTML text formatting for complete lists of supported HTML tags in Documotor and user styles, as well as examples.