Include HTML in documents

Prev Next

Exact Forms Plus can turn HTML stored in a Quickbase field into formatted text in the document: bold and italic text, headings, lists, tables, colors, and links. Use it for content that needs formatting a plain field can't hold, such as terms and conditions, a formatted description, or a block of text built with a formula.

For the other tokens you can use in a template, see Template fields and functions.

Which fields are converted

  • In the main part of the template: text fields, including formula text and rich text fields, that have Allow some HTML tags to be interpreted turned on. Exact Forms Plus reads this setting from the field's properties. You don't add anything to the token: ~Terms~ or ~45~ is enough. Text fields without the setting are inserted as plain text, tags and all.

  • In embedded reports: columns whose Type is Rich Text or Multi-select Text (shown as a bulleted list). The field setting isn't used there; the column type decides. See Choose and format columns.

Use the field name or field ID token (~Field Name~ or ~fid~). As with any field, it must be in the template's clist.

How the HTML appears in the document

  • The token is replaced with the converted content, as one or more paragraphs with no extra space before or after.

  • The HTML doesn't take the token's font. In the main part of the template, text uses the converter's default font (Times New Roman, 12 pt) unless the HTML sets one. To control the font, set it in the HTML, for example with a <span style="..."> around the content (see the example).

  • In embedded report cells, the HTML uses the font, size, and color of the ~strid=N~ text in the template, unless the HTML sets its own. Rich Text columns have no font settings in the configurator.

  • Field tokens inside the HTML, such as ~7~ typed into the field's value, aren't replaced. Build the text with a Quickbase formula instead.

Example: formatted terms from a formula

A formula rich text field named Terms HTML on the master table:

"<span style='font-family:Arial;font-size:10pt'>"
& "<h3>Payment terms</h3>"
& "<p>Payment is due within <b>" & ToText([Payment Days]) & " days</b> of the invoice date.</p>"
& "<ul><li>Late payments incur a 1.5% monthly fee.</li>"
& "<li>Questions? Contact <a href='mailto:" & [Account Manager Email] & "'>your account manager</a>.</li></ul>"
& "</span>"

In the Word template, put ~Terms HTML~ on its own line where the terms should appear, and add the field to the template's clist. The document shows a heading, a paragraph with the number of days in bold, and a two-item bulleted list with a link, all in Arial 10 pt.

Writing HTML that converts cleanly

Exact Forms Plus doesn't require strict XHTML, but the converter is less forgiving than a web browser. To avoid errors and surprises:

  • Close every tag you open: <p>…</p>, <li>…</li>, <div>…</div>. Don't write empty tags as <div />.

  • Put attribute values in quotes: <td width='40%'>.

  • Write a literal ampersand as &amp;. A lone & with a space on each side is fixed for you.

  • Line breaks: <br>, <br/>, and <br /> all work. A stray </br> is removed.

  • Colors: use hex values such as #1F4E79 in style attributes. HSL colors from the rich text editor are converted automatically.

  • Images pasted into a rich text field, and charts from quickchart.io, are converted with the rest of the HTML.

To check a piece of HTML, you can paste it into the W3C Markup Validator (Validate by Direct Input). Under More Options, choose to validate an HTML fragment, so the validator doesn't expect a full page.

Supported tags and styles

The converter supports the common formatting tags. Exact Forms Plus doesn't remove or block any tag; anything the converter doesn't support is ignored or causes an error (see If the HTML causes an error).

Tags

Notes

b, strong, i, em, u, s, strike, sub, sup, big, small, tt

Text formatting.

p, div, span, br, blockquote, h1–h6

p supports align; br supports clear.

pre

Shown in Courier.

ul, ol, li

Bulleted and numbered lists.

font

face, size, color. The size values normal and bigger aren't supported.

a

href, target, id, name.

table, thead, tbody, tfoot, tr, th, td

table: border, border-color, cellpadding, cellspacing, bgcolor, align, width. tr: height, align. th/td: width, rowspan, colspan, align, valign.

img

src, width, height, align. The src must be a full URL. But see Images in HTML fields: a field that contains an image link is normally inserted as an image, not as HTML.

Style attributes you can use in style="…":

  • Text: font-family, font-size, font-style, font-weight (bold or normal only), color (hex, #RRGGBB), background-color, text-align, text-decoration (underline and strikethrough only), text-indent, text-transform, letter-spacing, line-height, white-space.

  • Spacing: margin and margin-top/right/bottom/left, padding and padding-top/right/bottom/left.

  • Borders: border-top/right/bottom/left, border-color (hex), border-width, border-style, and the per-side color, width, and style properties.

  • Lists and pages: list-style-type, list-style-image, page-break-before, page-break-after.

Images in HTML fields

If a field's value contains an image tag (<img src=…>), Exact Forms Plus inserts it as an image, not as HTML:

  • Only the first image is used. Any other text or HTML in the field is left out.

  • Set the size with an image token, for example ~i:123:200~ (200 wide). A plain ~123~ inserts the image 300 wide. See Images.

  • If the image is inside a link, <a href='…'><img src='…'></a>, the link is kept on the image.

  • The src must be a full URL starting with http. Files in Quickbase file attachment fields are read with your account's access. Images on other websites must be publicly accessible.

  • If the image can't be downloaded, the document shows ERROR: followed by the URL and the reason, or ERROR-Invalid format: followed by the URL.

Example: to show an image from a URL field and make it a link, create a formula rich text field such as:

"<a href='https://www.example.com'><img src='" & [Image URL] & "'></a>"

and put ~i:fid:150~ in the template, using that field's ID. Images pasted directly into a rich text field are the exception: they're converted as part of the HTML, together with the text around them.

If the HTML causes an error

The document is still created. In place of the field, it shows the converter's error message, then ERROR FOUND IN THIS HTML-->: and the HTML that failed. In an embedded report cell, the message starts with HTML ERROR:.

To fix it:

  1. Copy the HTML shown after ERROR FOUND IN THIS HTML-->:.

  2. Look for an unclosed tag, an unquoted attribute, a lone &, or an unsupported tag. The W3C Markup Validator can help.

  3. Fix the field's value or formula and create the document again.

What you see

What to do

The tags appear as text, for example <b>Total</b>

Turn on Allow some HTML tags to be interpreted in the field's properties. In an embedded report, set the column's Type to Rich Text.

The text is in Times New Roman instead of the template's font

Set the font in the HTML, for example <span style='font-family:Arial;font-size:11pt'>…</span>.

Only an image appears and the rest of the field's text is missing

The field contains an image link, so it's inserted as an image. Put the image and the text in separate fields.

The token appears as typed

The field isn't in the template's clist. Add it with the EFP Configurator.

If you still need help, open a technical support case.

See also: Template fields and functions, Exact Forms Plus document templates, Insert embedded reports (subtable).