ParagraphIsEndOfSection Property

True if this paragraph is the last paragraph in the Body (main text story) of a Section; false otherwise.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


public bool IsEndOfSection { get; }

Property Value

Type: Boolean


Shows how to insert the contents of one document to a bookmark in another document.
public void InsertAtBookmark()
    Document mainDoc = new Document(MyDir + "Document insertion destination.docx");
    Document docToInsert = new Document(MyDir + "Document.docx");

    Bookmark bookmark = mainDoc.Range.Bookmarks["insertionPlace"];
    InsertDocument(bookmark.BookmarkStart.ParentNode, docToInsert);

    mainDoc.Save(ArtifactsDir + "NodeImporter.InsertAtBookmark.docx");

/// <summary>
/// Inserts content of the external document after the specified node.
/// </summary>
static void InsertDocument(Node insertionDestination, Document docToInsert)
    // Make sure that the node is either a paragraph or table
    if (insertionDestination.NodeType.Equals(NodeType.Paragraph) || insertionDestination.NodeType.Equals(NodeType.Table))
        // We will be inserting into the parent of the destination paragraph
        CompositeNode dstStory = insertionDestination.ParentNode;

        // This object will be translating styles and lists during the import
        NodeImporter importer =
            new NodeImporter(docToInsert, insertionDestination.Document, ImportFormatMode.KeepSourceFormatting);

        // Loop through all block level nodes in the body of the section
        foreach (Section srcSection in docToInsert.Sections.OfType<Section>())
            foreach (Node srcNode in srcSection.Body)
                // Skip the node if it is a last empty paragraph in a section
                if (srcNode.NodeType.Equals(NodeType.Paragraph))
                    Paragraph para = (Paragraph)srcNode;
                    if (para.IsEndOfSection && !para.HasChildNodes)

                // This creates a clone of the node, suitable for insertion into the destination document
                Node newNode = importer.ImportNode(srcNode, true);

                // Insert new node after the reference node
                dstStory.InsertAfter(newNode, insertionDestination);
                insertionDestination = newNode;
        throw new ArgumentException("The destination node should be either a paragraph or table.");

ExpandedSee Also