public class HtmlInsertOptions
extends java.lang.Object
Examples:
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");
| Modifier and Type | Field and Description |
|---|---|
static int |
length |
static int |
NONE
Use the default options when inserting HTML.
|
static int |
PRESERVE_BLOCKS
Preserve properties of block-level elements.
|
static int |
REMOVE_LAST_EMPTY_PARAGRAPH
Remove the empty paragraph that is normally inserted after HTML that ends with a block-level element.
|
static int |
USE_BUILDER_FORMATTING
Use font and paragraph formatting specified in
DocumentBuilder as base formatting for text inserted from HTML. |
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String htmlInsertOptionsName) |
static int |
fromNames(java.util.Set htmlInsertOptionsNames) |
static java.lang.String |
getName(int htmlInsertOptions) |
static java.util.Set |
getNames(int htmlInsertOptions) |
static int[] |
getValues() |
static java.lang.String |
toString(int htmlInsertOptions) |
static java.lang.String |
toStringSet(int attr) |
public static int NONE
public static int USE_BUILDER_FORMATTING
DocumentBuilder as base formatting for text inserted from HTML.
Remarks:
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).
public static int REMOVE_LAST_EMPTY_PARAGRAPH
Remarks:
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.
public static int PRESERVE_BLOCKS
Remarks:
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.
public static int length
public static java.lang.String getName(int htmlInsertOptions)
public static java.util.Set getNames(int htmlInsertOptions)
public static java.lang.String toString(int htmlInsertOptions)
public static java.lang.String toStringSet(int attr)
public static int fromName(java.lang.String htmlInsertOptionsName)
public static int fromNames(java.util.Set htmlInsertOptionsNames)
public static int[] getValues()