insert_document_inline method

insert_document_inline(src_doc, import_format_mode, import_format_options)

Inserts a document inline at the cursor position.

def insert_document_inline(self, src_doc: aspose.words.Document, import_format_mode: aspose.words.ImportFormatMode, import_format_options: aspose.words.ImportFormatOptions):
    ...
ParameterTypeDescription
src_docDocumentSource document for inserting.
import_format_modeImportFormatModeSpecifies how to merge style formatting that clashes.
import_format_optionsImportFormatOptionsAllows to specify options that affect formatting of a result document.

Remarks

This method mimics the MS Word behavior, as if CTRL+‘A’ (select all content) was pressed, then CTRL+‘C’ (copy selected into the buffer) inside one document and then CTRL+‘V’ (insert content from the buffer) inside another document.

As a difference from DocumentBuilder.insert_document() this method moves the content of the paragraph of the destination document, before which the source document is inserted, into the last paragraph of the inserted source document. Actually, this means that paragraph break of the last inserted paragraph is removed.

Note, if the last node of the source document is not a paragraph, then nothing will be done.

Returns

First node of the inserted content.

Examples

Shows how to insert a document inline at the cursor position.

src_doc = aw.DocumentBuilder()
src_doc.write('[src content]')
# Create destination document.
dst_doc = aw.DocumentBuilder()
dst_doc.write('Before ')
dst_doc.insert_node(aw.BookmarkStart(dst_doc.document, 'src_place'))
dst_doc.insert_node(aw.BookmarkEnd(dst_doc.document, 'src_place'))
dst_doc.write(' after')
self.assertEqual('Before  after', dst_doc.document.get_text().strip())
# Insert source document into destination inline.
dst_doc.move_to_bookmark('src_place')
dst_doc.insert_document_inline(src_doc.document, aw.ImportFormatMode.USE_DESTINATION_STYLES, aw.ImportFormatOptions())
self.assertEqual('Before [src content] after', dst_doc.document.get_text().strip())

See Also