HtmlInsertOptions enumeration

HtmlInsertOptions enumeration

Specifies options for the DocumentBuilder.insert_html() method.


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.


Shows how to allows better preserve borders and margins seen.

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.
insert_options = aw.HtmlInsertOptions.PRESERVE_BLOCKS
builder = aw.DocumentBuilder()
builder.insert_html(html=html, options=insert_options) + 'DocumentBuilder.PreserveBlocks.docx')

See Also