Class BookmarkCollection
Represents the collection of Bookmark in the Word document.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class BookmarkCollection : CollectionImpl
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the bookmark instance with bookmark name
Syncfusion.DocIO.DLS.Bookmark bookmark = document.Bookmarks["Northwind"];
//Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the bookmark instance with bookmark name
Dim bookmark As Syncfusion.DocIO.DLS.Bookmark = document.Bookmarks("Northwind")
'Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
Properties
Item[Int32]
Gets the Bookmark at the specified index.
Declaration
public Bookmark this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The integer that represents the position of the bookmark in the document to get. |
Property Value
Type | Description |
---|---|
Bookmark | The Bookmark at the specified index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid in the BookmarkCollection |
Item[String]
Gets the Bookmark with the specified name.
Declaration
public Bookmark this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The string that represents the name of the bookmark in the document to get. |
Property Value
Type | Description |
---|---|
Bookmark | The Bookmark with the specified name. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The specified bookmark name is not present in the document. |
Methods
Clear()
Removes all the bookmarks in the document.
Declaration
public void Clear()
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Remove all the bookmarks from Word document
document.Bookmarks.Clear();
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Remove all the bookmarks from Word document
document.Bookmarks.Clear()
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
FindByName(String)
Finds Bookmark with specific name in the document.
Declaration
public Bookmark FindByName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The string that represents the name of the bookmark to find. |
Returns
Type | Description |
---|---|
Bookmark | The Bookmark with the specified name. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Bookmark bookmark = document.Bookmarks.FindByName("Northwind");
//Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Dim bookmark As Bookmark = document.Bookmarks.FindByName("Northwind")
'Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
Remove(Bookmark)
Removes the specified bookmark from the document.
Declaration
public void Remove(Bookmark bookmark)
Parameters
Type | Name | Description |
---|---|---|
Bookmark | bookmark | The Bookmark to be removed. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Bookmark bookmark = document.Bookmarks.FindByName("Northwind");
//Remove the bookmark named "Northwind" from Word document.
document.Bookmarks.Remove(bookmark);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Dim bookmark As Bookmark = document.Bookmarks.FindByName("Northwind")
'Remove the bookmark named "Northwind" from Word document.
document.Bookmarks.Remove(bookmark)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
RemoveAt(Int32)
Removes a bookmark at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The integer that represents the position of the bookmark to remove. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Remove the bookmark at the second index from Word document.
document.Bookmarks.RemoveAt(1);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Remove the bookmark at the second index from Word document.
document.Bookmarks.RemoveAt(1)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid in the BookmarkCollection. |