Table of Contents

Class PdfBookmarkBase

Namespace
Syncfusion.Pdf.Interactive
Assembly
Syncfusion.Pdf.Portable.dll

This class plays two roles: it's a base class for all bookmarks and it's a root of a bookmarks tree.

public class PdfBookmarkBase : IEnumerable
Inheritance
PdfBookmarkBase
Implements
Derived
Inherited Members

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.

public int Count { get; }

Property Value

int

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

this[int]

Gets the PdfBookmark at the specified index. Read-Only.

public PdfBookmark this[int index] { get; }

Parameters

index int

Property Value

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.

public PdfBookmark Add(string title)

Parameters

title string

The title of the new outline.

Returns

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.

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.

public bool Contains(PdfBookmark outline)

Parameters

outline PdfBookmark

The outline.

Returns

bool

true if the specified outline is in the collection; otherwise, false.

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(int, string)

Inserts a new outline at the specified index.

public PdfBookmark Insert(int index, string title)

Parameters

index int

The index.

title string

The title of the new outline.

Returns

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.

public void Remove(string title)

Parameters

title string

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(int)

Remove the bookmark from the document at the specified index.

public void RemoveAt(int index)

Parameters

index int

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)
See Also

See Also