Syncfusion.DocIO.Base
Example 


The string that specifies the text.
True if to save formatting, otherwise false.

ReplaceBookmarkContent(String,Boolean) Method

Replaces the content of the bookmark with the specified text and formatting.
Syntax
'Declaration
 
Public Overloads Sub ReplaceBookmarkContent( _
   ByVal text As String, _
   ByVal saveFormatting As Boolean _
) 
'Usage
 
Dim instance As BookmarksNavigator
Dim text As String
Dim saveFormatting As Boolean
 
instance.ReplaceBookmarkContent(text, saveFormatting)
public void ReplaceBookmarkContent( 
   string text,
   bool saveFormatting
)

Parameters

text
The string that specifies the text.
saveFormatting
True if to save formatting, otherwise false.
Example

The following code example demonstrates how to replace a specified bookmark content with simple text along with its formatting.

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);
    document.AddSection();
    IWParagraph paragraph = document.LastSection.AddParagraph();
    //Add the new bookmark into Word document
    paragraph.AppendBookmarkStart("bm_empty");
    paragraph.AppendBookmarkEnd("bm_empty");
    //Move to the virtual cursor before the end location of the bookmark "bm_empty"
    bookmarkNavigator.MoveToBookmark("bm_empty");
    //Replace the bookmark content with text body part
    bookmarkNavigator.ReplaceBookmarkContent(" Northwind Database is a set of tables containing data fitted into predefined categories.", true);
    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)
    document.AddSection()
    Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
    'Add the new bookmark into Word document
    paragraph.AppendBookmarkStart("bm_empty")
    paragraph.AppendBookmarkEnd("bm_empty")
    'Move to the virtual cursor before the end location of the bookmark "bm_empty"
    bookmarkNavigator.MoveToBookmark("bm_empty")
    'Replace the bookmark content with text body part
    bookmarkNavigator.ReplaceBookmarkContent(" Northwind Database is a set of tables containing data fitted into predefined categories.", True)
    document.Save("Result.docx", FormatType.Docx)
    document.Close()
End Sub
AssemblyVersion

Syncfusion.DocIO.Base: 17.1460.0.47

See Also