Class PdfBookmarkBase
This class plays two roles: it's a base class for all bookmarks and it's a root of a bookmarks tree.
Implements
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Portable.dll
Syntax
public class PdfBookmarkBase : Object, IPdfWrapper, IEnumerable
Examples
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Get all the bookmarks.
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
//get the bookmark count.
int count = bookmarks.Count;
//Save and close the document
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Get all the bookmarks.
Dim bookmarks As PdfBookmarkBase = loadedDocument.Bookmarks
'get the bookmark count.
Dim count As Integer = bookmarks.Count
'Save and close the document
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
Properties
Count
Gets number of the elements in the collection. Read-Only.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The value which contains count of the collection. |
Examples
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Get all the bookmarks.
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
//get the bookmark count.
int count = bookmarks.Count;
//Save and close the document
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Get all the bookmarks.
Dim bookmarks As PdfBookmarkBase = loadedDocument.Bookmarks
'get the bookmark count.
Dim count As Integer = bookmarks.Count
'Save and close the document
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
Item[Int32]
Gets the PdfBookmark at the specified index. Read-Only.
Declaration
public PdfBookmark this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
PdfBookmark | The PdfBookmark object returns from the collection by index. |
Examples
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Get all the bookmarks.
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
//Get the first bookmark and change the properties of the bookmark.
PdfLoadedBookmark bookmark = bookmarks[0] as PdfLoadedBookmark;
bookmark.Destination = new PdfDestination(loadedDocument.Pages[1]);
bookmark.Color = Color.Green;
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Title = "Changed title";
//Save the document
loadedDocument.Save("Output.pdf");
//Close the document
loadedDocument.Close(true);
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Get all the bookmarks.
Dim bookmarks As PdfBookmarkBase = document.Bookmarks
'Get the first bookmark and change the properties of the bookmark.
Dim bookmark As PdfLoadedBookmark = TryCast(bookmarks(0), PdfLoadedBookmark)
bookmark.Destination = New PdfDestination(loadedDocument.Pages(1))
bookmark.Color = Color.Green
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Title = "Changed title"
'Save the document
loadedDocument.Save("Output.pdf")
'Close the document
loadedDocument.Close(True)
See Also
Methods
Add(String)
Creates and adds an outline.
Declaration
public PdfBookmark Add(string title)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title of the new outline. |
Returns
Type | Description |
---|---|
PdfBookmark | PdfBookmark |
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Set the destination page.
bookmark.Destination = new PdfDestination(page);
//Set the destination location.
bookmark.Destination.Location = new PointF(20, 20);
//Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold;
bookmark.Color = Color.Red;
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Set the destination page.
bookmark.Destination = New PdfDestination(page)
'Set the destination location.
bookmark.Destination.Location = New PointF(20, 20)
'Set the text style and color.
bookmark.TextStyle = PdfTextStyle.Bold
bookmark.Color = Color.Red
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Clear()
Removes all the bookmark from the collection.
Declaration
public void Clear()
Examples
//Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Get the bookmarks
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
//Remove all the bookmarks form the collection
bookmarks.Clear();
//Save and close the PDF document
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Get the Bookmarks
Dim Bookmarks As PdfAttachmentCollection = loadedDocument.Bookmarks
'Remove all the bookmarks form the collection
Bookmarks.Clear()
'Save and close the document
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
Contains(PdfBookmark)
Determines whether the specified outline presents in the collection.
Declaration
public bool Contains(PdfBookmark outline)
Parameters
Type | Name | Description |
---|---|---|
PdfBookmark | outline | The outline. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Examples
//Create a new document.
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create document bookmarks.
PdfBookmark bookmark = document.Bookmarks.Add("Page 1");
//Set the destination page.
bookmark.Destination = new PdfDestination(page);
//check whether the specified bookmark present in the collection
document.Bookmarks.Contains(bookmark);
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new document.
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create document bookmarks.
Dim bookmark As PdfBookmark = document.Bookmarks.Add("Page 1")
'Set the destination page.
bookmark.Destination = New PdfDestination(page)
'Set the destination location.
bookmark.Destination.Location = New PointF(20, 20)
'check whether the specified bookmark present in the collection
Dim isBookMarkContained As Boolean = document.Bookmarks.Contains(bookmark)
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Insert(Int32, String)
Inserts a new outline at the specified index.
Declaration
public PdfBookmark Insert(int index, string title)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
System.String | title | The title of the new outline. |
Returns
Type | Description |
---|---|
PdfBookmark | The new outline. |
Examples
//Create a new document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Insert a new bookmark in the existing bookmark collection.
PdfBookmark bookmark = loadedDocument.Bookmarks.Insert(1, "New bookmark 2");
//Set the destination page and location.
bookmark.Destination = new PdfDestination(loadedDocument.Pages[1]);
bookmark.Destination.Location = new PointF(0, 300);
//Save and close the PDF document.
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Create a new document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Insert a new bookmark in the existing bookmark collection.
Dim bookmark As PdfBookmark = loadedDocument.Bookmarks.Insert(1, "New bookmark 2")
'Set the destination page and location.
bookmark.Destination = New PdfDestination(loadedDocument.Pages(1))
bookmark.Destination.Location = New PointF(0, 300)
'Save and close the PDF document.
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
Remove(String)
Remove the specified bookmark from the document.
Declaration
public void Remove(string title)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title of the outline. |
Examples
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");
//Get all the bookmarks.
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
//Remove bookmark by bookmark name.
bookmarks.Remove("Page 1");
//Save and close the document.
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("input.pdf")
'Get all the bookmarks.
Dim bookmarks As PdfBookmarkBase = loadedDocument.Bookmarks
'Remove bookmark by bookmark name.
bookmarks.Remove("Page 1")
'Save and close the document.
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
RemoveAt(Int32)
Remove the bookmark from the document at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
Examples
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");
//Get all the bookmarks.
PdfBookmarkBase bookmarks = loadedDocument.Bookmarks;
//Remove bookmark by index.
bookmarks.RemoveAt(0);
//Save and close the document.
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("input.pdf")
'Get all the bookmarks.
Dim bookmarks As PdfBookmarkBase = loadedDocument.Bookmarks
'Remove bookmark by index.
bookmarks.RemoveAt(0)
'Save and close the document.
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)