HtmlInsertOptions enumeration

HtmlInsertOptions enumeration

Specifies options for the DocumentBuilder.insert_html() method.

Members

NameDescription
NONEUse the default options when inserting HTML.
USE_BUILDER_FORMATTINGUse font and paragraph formatting specified in DocumentBuilder as base formatting for text inserted from HTML.
REMOVE_LAST_EMPTY_PARAGRAPHRemove the empty paragraph that is normally inserted after HTML that ends with a block-level element.
PRESERVE_BLOCKSPreserve properties of block-level elements.

Examples

Shows how to allows better preserve borders and margins seen.

html = "<html><div style='border:dotted'><div style='border:solid'><p>paragraph 1</p><p>paragraph 2</p></div></div></html>"
# Set the new mode of import HTML block-level elements.
insert_options = aw.HtmlInsertOptions.PRESERVE_BLOCKS
builder = aw.DocumentBuilder()
builder.insert_html(html, insert_options)
builder.document.save(ARTIFACTS_DIR + "DocumentBuilder.PreserveBlocks.docx")

See Also