Richtext Styles

Structure

{mainTitle}

{mainTitle}

{subTitle}

empty or {content}

Behavior

Richtext nodes are produced by filling out a word table template with main title, subtitle and html content. The tags in the html fragment can optionally be translated to word styles. The configuration of this mapping happens like this:

  1. If the html element has a class defined, it is used as the word style

  2. The mapping defined in the style’s metadata is used

  3. The mapping defined in application.properties is used

  4. If none is provided, the Aspose.Words mapping is applied

The application.properties entries look as follows:

richtextnode.htmltagmapping.<html tag>=<name of word style>

Example:

richtextnode.htmltagmapping.h1=Header1

If no style is specified, the content is produced inline without a style. The rules for translating the HTML above still apply though.

If a style is defined, the HTML content is produced in the cell with a {content} placeholder or if there is none, the first empty cell is used.

Metadata

The metadata has the following structure:

{ "default": true, "htmlTagToWordStyle": { "h1": "P_H1", "h2": "P_H2" } }

In addition to defining default styles it is possible to define a HTML tag to Word style mapping. The following HTML tags are supported:

  • h1-h6

  • p

  • ul

  • ol

Examples

Example 1: Showing a simple case with a style

Example 2: Showing what happens if no style is specified

Example 3: Showing how to specify a word style in HTML by using classes

Example 4: Showing how the mapping in the metadata works

Example 5: Showing how the mapping in the configuration file works