Some test text!

Search
Hamburger Icon

Nodejs / Guides / Structured Input

Document Generation Structured Input

Overview

The template engine can fill template tags with structured input, which is more powerful than simple text. It supports:

  • styled text
  • paragraphs
  • lists
  • hyperlinks
  • headers
  • more (see below)

Structured input can be provided as either HTML or markdown, by supplying a JSON object with the property "html" or "markdown". Example:

{
    "template_tag_1": {
        "markdown": "# Markdown demo\nHello *world*\n\n---\n"
    },
    "template_tag_2": {
        "html": "<u>Underlined text <span style='color: red'>red text</span></u>"
    }
}

In markdown and HTML whitespace is treated differently than normal template text filling. In HTML, whitespace after an opening tag and before a closing tag is ignored, and all other whitespace is converted to a singe space.

Markdown input can also use inline HTML.

We are interested in expanding the breadth of features for HTML, markdown, and CSS, so please contact us if you have any features suggestions!


Styled text

Spans of text can be styled individually. With both markdown and HTML input, you can style text to be:

  • Bold
  • Italic
  • Strikethrough

HTML input additionally supports underlined text, as well as the following properties using inline css:

  • font-size (specified in absolute units)
  • font-family
  • color (specified by hex color (prefixed with #), named color (eg. red), rgb(r, g, b), or rgba(r, g, b, a))
  • background-color

Example:

<span style='font-size: 12pt; font-family: "monospace"; color: #ff00ff; background-color: yellow'>Funky text</span>

Lists

Unordered and ordered lists are supported in both HTML and markdown. A list item will break a paragraph, see paragraphs. By default, the bullets and numbering styles are similar to Microsoft Word. With HTML input, this can be changed using the CSS property list-style. Ordered lists support decimal, alpha, and roman numbering. Unordered lists support any bullet character. Example:

<ul style='list-type: ">";'>
    <li>Bulleted item</li>
    <ol style='list-type: lower-roman; font-weight: bold'>
        <li style='font-weight: normal'>Numbered item</li>
    </ol>
</ul>

Hyperlinks

Hyperlinks are supported in both HTML and markdown. Hyperlinks are automatically styled to be blue and underlined. If this is undesirable, you can override it using inline CSS. Example:

<a style='text-decoration: none; color: black' href='https://pdftron.com'>Click me</a>

Headings

Headings 1-6 are supported in both HTML and markdown. The heading style is extracted from the template document itself. If you wish to change the heading styles, modify the styles "Heading 1", "Heading 2", etc. of the template document in your word processor. Alternatively, modify the style using inline CSS.


Paragraphs

The inserted text can be made up of multiple paragraphs. This is supported in both HTML (using <p>) and markdown (using two newlines). If the template tag appears in the middle of a paragraph and the input contains multiple paragraphs, the tag's paragraph will be split to accommodate the inserted paragraph breaks, as if a user was typing the inserted text in and inserts a paragraph break.


Other

Line breaks are supported in HTML (<br>). Horizontal lines are supported in HTML (<hr>) and markdown (--- on a separate line).

Get the answers you need: Chat with us