Syncfusion.DocIO.Base
Example 


GetBookmarkContent Method

Returns the bookmark content as a TextBodyPart, which represents the collection of body items if the bookmark start and bookmark end are preserved in a single section.
Syntax
'Declaration
 
Public Function GetBookmarkContent() As TextBodyPart
'Usage
 
Dim instance As BookmarksNavigator
Dim value As TextBodyPart
 
value = instance.GetBookmarkContent()
public TextBodyPart GetBookmarkContent()

Return Value

The TextBodyPart that represents the bookmark content.
Example
This example shows how to retrieve the specified bookmark content using GetBookmarkContent method in a Word document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
    //Create the bookmark navigator instance to access the bookmark
    BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
    //Move the virtual cursor to the before the end location of the bookmark "Northwind"
    bookmarkNavigator.MoveToBookmark("Northwind");
    //Get the bookmark content
    TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
    //Add the retrieved content into another new section
    document.AddSection();
    foreach(TextBodyItem item in part.BodyItems)
        document.LastSection.Body.ChildEntities.Add(item);
    document.Save("Result.docx", FormatType.Docx);
        document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
    Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
    'Create the bookmark navigator instance to access the bookmark
    Dim bookmarkNavigator As New BookmarksNavigator(document)
    'Move the virtual cursor to the before the end location of the bookmark "Northwind"
    bookmarkNavigator.MoveToBookmark("Northwind")
    'Get the bookmark content
    Dim part As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
    'Add the retrieved content into another new section
    document.AddSection()
    For Each item As TextBodyItem In part.BodyItems
        document.LastSection.Body.ChildEntities.Add(item)
    Next
    document.Save("Result.docx", FormatType.Docx)
    document.Close()
End Sub
AssemblyVersion

Syncfusion.DocIO.Base: 17.1460.0.47

See Also