Represents a single bookmark.
Inheritance Hierarchy Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.12.16
Syntax public sealed class Bookmark
Public NotInheritable Class Bookmark
The Bookmark type exposes the following members.
Properties Methods | Name | Description |
---|
| GetContent |
Gets the content of the current Bookmark.
|
TopRemarks
Bookmark is a "facade" object that encapsulates two elements
BookmarkStart and
BookmarkEnd
in a document and allows to work with a bookmark as a single object.
Example See Developer Guide: How add a text bounded by BookmarkStart and BookmarkEnd
How add a text bounded by BookmarkStart and BookmarkEnd using C#
using SautinSoft.Document;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
AddBookmarks();
}
public static void AddBookmarks()
{
string documentPath = @"Bookmarks.docx";
DocumentCore dc = new DocumentCore();
dc.Sections.Add(
new Section(dc,
new Paragraph(dc,
new Run(dc, "Text before bookmark. "),
new BookmarkStart(dc, "SimpleBookmark"),
new Run(dc, "Text inside bookmark."),
new BookmarkEnd(dc, "SimpleBookmark"),
new Run(dc, " Text after bookmark.")),
new Paragraph(dc,
new SpecialCharacter(dc, SpecialCharacterType.PageBreak),
new Hyperlink(dc, "SimpleBookmark", "Go to Simple Bookmark.") { IsBookmarkLink = true })));
dc.Bookmarks["SimpleBookmark"].GetContent(false).Replace("Some text inside bookmark.");
dc.Save(documentPath);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true });
}
}
}
How add a text bounded by BookmarkStart and BookmarkEnd using VB.Net
Imports SautinSoft.Document
Namespace Sample
Friend Class Sample
Shared Sub Main(ByVal args() As String)
AddBookmarks()
End Sub
Public Shared Sub AddBookmarks()
Dim documentPath As String = "Bookmarks.docx"
Dim dc As New DocumentCore()
dc.Sections.Add(New Section(dc, New Paragraph(dc, New Run(dc, "Text before bookmark. "), New BookmarkStart(dc, "SimpleBookmark"), New Run(dc, "Text inside bookmark."), New BookmarkEnd(dc, "SimpleBookmark"), New Run(dc, " Text after bookmark.")), New Paragraph(dc, New SpecialCharacter(dc, SpecialCharacterType.PageBreak), New Hyperlink(dc, "SimpleBookmark", "Go to Simple Bookmark.") With {.IsBookmarkLink = True})))
dc.Bookmarks("SimpleBookmark").GetContent(False).Replace("Some text inside bookmark.")
dc.Save(documentPath)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True})
End Sub
End Class
End Namespace
See Also