com.aspose.words
Class HtmlInsertOptions

java.lang.Object
    extended by com.aspose.words.HtmlInsertOptions

public class HtmlInsertOptions 
extends java.lang.Object

Utility class containing constants. Specifies options for the DocumentBuilder.insertHtml(java.lang.String,int) method.

Example:

Shows how to allows better preserve borders and margins seen.
final String HTML = "\n                <html>\n                    <div style='border:dotted'>\n                    <div style='border:solid'>\n                        <p>paragraph 1</p>\n                        <p>paragraph 2</p>\n                    </div>\n                    </div>\n                </html>";

// Set the new mode of import HTML block-level elements.
int insertOptions = HtmlInsertOptions.PRESERVE_BLOCKS;

DocumentBuilder builder = new DocumentBuilder();
builder.insertHtml(HTML, insertOptions);
builder.getDocument().save(getArtifactsDir() + "DocumentBuilder.PreserveBlocks.docx");

Field Summary
static final intNONE = 0
           Use the default options when inserting HTML.
static final intUSE_BUILDER_FORMATTING = 1
           Use font and paragraph formatting specified in DocumentBuilder as base formatting for text inserted from HTML.
static final intREMOVE_LAST_EMPTY_PARAGRAPH = 2
           Remove the empty paragraph that is normally inserted after HTML that ends with a block-level element.
static final intPRESERVE_BLOCKS = 4
           Preserve properties of block-level elements.
 

Field Detail

NONE = 0

public static final int NONE
Use the default options when inserting HTML.

USE_BUILDER_FORMATTING = 1

public static final int USE_BUILDER_FORMATTING
Use font and paragraph formatting specified in DocumentBuilder as base formatting for text inserted from HTML.

If this option is not specified, formatting of DocumentBuilder is ignored and text is inserted with default HTML formatting. As a result, the text looks as it is rendered in browsers.

If this option is specified, formatting of inserted text is based on formatting specified in DocumentBuilder, and the text looks as if it were inserted using DocumentBuilder.write(java.lang.String).


REMOVE_LAST_EMPTY_PARAGRAPH = 2

public static final int REMOVE_LAST_EMPTY_PARAGRAPH
Remove the empty paragraph that is normally inserted after HTML that ends with a block-level element. By default, DocumentBuilder makes sure that the last block-level element imported from HTML is closed after import and inserts a paragraph break after the element. This paragraph break separates content imported from HTML from content of the template document. However, if a HTML fragment is inserted into an empty paragraph, that paragraph break will create an extra empty paragraph. If this behavior is undesired, specify this option.

PRESERVE_BLOCKS = 4

public static final int PRESERVE_BLOCKS
Preserve properties of block-level elements.

By default, properties of parent blocks are merged and stored on their child elements (i.e. paragraphs or tables). If this option is specified, properties of each block are stored separately in a special logical structure. As a result, this option allows to better preserve individual borders and margins seen in the HTML document and get better conversion results. The downside is that the resulting document gets harder to modify, since borders and margins stored in the logical structure are not available for editing.

Only margins and borders of 'body', 'div', and 'blockquote' HTML elements are preserved. Properties of each HTML element are stored separately.

If this option is specified, Aspose.Words mimics MS Word's behavior regarding import of block properties.


See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.