When including HTML fields into a template, you may need to format them to account for certain HTML complexities or to give your template a specific look and/or feel. This article covers the properties and settings of the HTML field.
Note: Some of the features referred to in this article require DocumentsCorePack Template Designer 10.50 and DocumentsCorePack Server 2020.169. Please ensure that both are up to date.
HTML field properties
Add an HTML field by selecting ❶ a field within the Standard or Additional tab and clicking on the ❷ Insert Field dropdown. Under the listed options, click on ❸ Insert as HTML.
Under the field’s properties, we can adjust the ❶ Import Type and the ❷ Encoding.
Import Type
There are four options under import type. Note that HTML Plain and Single Encoding are deprecated import types available only for compatibility with older versions:
- HTML Plain: Apply no encoding upon import.
- Single Encoding: For usage with style sheets and if single encoding has been applied to special characters.
- Double Encoding: To be used when style sheets are applied in MS Word on the respective field. Apply Double Encoding upon import to handle special characters.
- As External Content: To be used when no style sheets are applied in MS Word on the respective field and the source format should be kept.
The default selection is As External Content, which is the native OpenXML and recommended option for inserting HTML.
For HTML Plain, Single Encoding, and Double Encoding import types, enable❷ Enable HTML Formatting For Fields setting in the Advanced Template Settings under the ❶ General tab to display their contents in the default (“Normal”) Word style. You do not need to activate this setting if you select the As External Content import type.
Formatting HTML fields
Changing the font of an HTML field in a template will not alter how its contents are displayed in a generated document. The field will take on the default style of the document instead. Change the default style to modify the appearance of an HTML field’s contents.
For hyperlinks within HTML fields, configure the “Hyperlink” style separately to distinguish the link in the generated document.
Pre-Processing HTML with Rich Text fields
Sometimes, unintended formatting issues may occur when inserting a rich text field as HTML into a template. You can resolve this by implementing an HTML pre-processing rule to match the field’s formatting with the rest of your document. To implement this, add the following SettingsKey:
- Name: HTMLPreProcessingRules
- Product: DocumentsCorePack
- Value: Copy and paste the code below:
{
"RuleSets": [
{
"Name": "defaultrule",
"DisplayName": "Default Rule",
"Description": "This rule aims to eliminate the default font and size specifications from the HTML generated by the default RichText Control. By doing so, it ensures that the content aligns better with the styling of your document.",
"DefaultRuleSet": true,
"Rules": {
"GlobalStylingRules": [
{
"styling": "font-family"
},
{
"styling": "font-size"
}
],
"NodeTypeRules": [
{
"nodeType": "div",
"attributeRules": [
{
"attribute": "data-wrapper"
}
]
}
]
}
}
]
}
Once you save the SettingsKey, restart your Word instance. Once you enable the Processing Rule option in the HTML field properties window, and you can select the rules.
Note: When this rule is used, rich text fields will display their contents based on the Normal (Web) style, not the default Normal style. Please keep this in mind when using this setting.
You can always remove this rule by deleting the SettingsKey. To modify or extend this HTML pre-processing rule, please contact support.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com!