Map Styles

Export can map paragraph and character styles in any word processing format that contains styles (such as Microsoft Word, RTF, or Folio Flat File) to user-defined markup. This feature is useful for shaping the look of the HTML output, or for generating user-defined metadata (including using XML tags) for indexing, searching, and navigation. With this feature, you can redact (hide) text in the source document, delete content, or change the overall structure of the output. You can also embed style sheet styles in the output defined in the HTML.

To enable style mapping, you must indicate which paragraph and/or character styles are to be mapped, and define the starting and ending markup to be included in the HTML output. For example, if the source Microsoft Word document contains the character style “Recipe,” and the content of the style in Microsoft Word is “Brownies,” you can specify that the starting markup be <recipe> and the ending markup </recipe>. This would result in the output HTML containing: <recipe>Brownies</recipe>.

You can also use style mapping to control the look of the HTML output either by using a Cascading Style Sheet (CSS) or by defining the style directly in the starting markup. For example, if a Word document contains the paragraph style “Colorful”, you can have markup of the form <p><div class=”rainbow”> inserted at the front of the paragraph and markup of the form </div></p> inserted at the end of the paragraph. “Rainbow” is a CSS style defined in an externally provided CSS file referenced at the top of the HTML output.

Style mapping is enabled in the wordstyle.ini template file. The HTML Export Getting Started page demonstrates the output resulting from a conversion using wordstyle.ini. The Getting Started page, named htmstart.html, is in the install\htmlexport\docs directory, where install is the path name of the Export installation directory. The source documents used in the page are in the directory install\testdocs.

NOTE: Note: When the user-defined markup in KVStyle conflicts with other markup generated by HTML Export, the user-defined markup takes precedence.

Use the Java API

To map styles using the Java API

  1. Create an instance of the StyleMapping class. Using the object’s methods, specify the style mapping information. The information includes

  2. Call the setStyleMapping() method of the Export object and pass the StyleMapping object.

Use a Template file

To map styles using a template file

  1. Use the KVStyle parameter to specify how many styles are being mapped. For example, if there are nine mapped heading levels, add the following:

  2. For each style, there must be a [StyleX] entry that contains the markup that appears at the start and end of the defined style. For example, in the wordstyle.ini sample file, the first heading level is defined as follows:

    MarkUpStart=<div class="colorful">
    MarkUpEnd=<!-- end of colorful --></div>
  3. For each style, define the flag that applies. Flags define instructions on how to process the content associated with a paragraph or character style. They are defined as constants in the Export class and listed in Flags for Defining Styles.

  4. A finished entry in a template file could look like this:

    MarkUpStart=<div class="Colorful">
    MarkUpEnd=<!-- End of Colorful --></div>
    MarkUpStart=<div class="RedactPara">
    MarkUpEnd=<!-- End of RedactPara --></div>
    MarkUpEnd=<!-- End of Code --></pre>

    Flags for Defining Styles




    The KVSTYLE_PRE flag specifies that white space should be preserved (treated as characters, not word separators), and that mode changes, such as changes in font size within a paragraph, should be ignored. This allows the tags <pre> and </pre> to be used.


    The KVSTYLE_HEADING[1-6] flags specify that a specific style is to be detected and processed as a heading. Heading flags are exclusive. This means that a style cannot be processed as both h1 and h2.

    By default, Export maps the heading style “Heading 1” to <h1></h1>, and so on, for heading levels 1 through 6. If you use style mappings, the default mapping is overridden. Therefore, you must supply markup for all heading levels. HTML Export uses heading levels to define the overall structure of the HTML output.


    The KVSTYLE_ORDERLIST flag specifies that the style should be tagged as an ordered list. Currently not implemented.


    The KVSTYLE_UNORDERLIST flag specifies that the style should be tagged as an unordered list. Currently not implemented.


    The KVSTYLE_DELETECONTENT flag specifies that the content associated with the style tag should be deleted from the output.


    The KVSTYLE_ONCONSECUTIVEPARAGRAPHS flag specifies that the style should be applied to consecutive paragraphs of the document. If this flag is used, and two or more paragraphs require the same style, the opening and closing tags that normally appear between each paragraph are not generated.


    The KVSTYLE_REDACT flag is used to hide sensitive or confidential information in the source document. It specifies that the text associated with the style tag should be replaced in the HTML output with a selected character. The default replacement character is "X", but you can specify a different replacement character by using the setRedact(java.lang.Byte b) method of the OptionInfo class.


    The KVSTYLE_DEFAULT flag specifies that special processing should not be applied to the content.