Syncfusion AI Assistant

How can I help you?

PdfBookmarkBase

21 Apr 20268 minutes to read

Represents a base class for all bookmark objects.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Destroy the document
document.destroy();

Properties

Get count number

Gets the bookmark count (Read only).

Get isExpanded boolean

Gets the boolean flag indicating whether the bookmark is expanded or not.

Set isExpanded void

Sets the boolean flag indicating whether the bookmark is expanded or not.

Parameter Type Description
value boolean Whether the bookmark is expanded or not.

Methods

add

Creates and adds a new outline to the PDF document.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the PDF
let page: PdfPage = document.getPage(0);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Add a new outline to the PDF document
let bookmark: PdfBookmark = bookmarks.add('Introduction');
// Sets destination to the bookmark
bookmark.destination = new PdfDestination(page, {x: 10, y: 10});
// Destroy the document
document.destroy();
Parameter Type Description
title string The title of the outline.

Returns PdfBookmark

add

Adds a new outline (bookmark) with title and optional properties to the PDF document .

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the PDF
let page: PdfPage = document.getPage(0);
// Add a new bookmark with destination
let bookmark: PdfBookmark = document.bookmarks.add('Introduction', {
   destination: new PdfDestination(page, { x: 10, y: 10 }, { zoom: 1 }),
   namedDestination: new PdfNamedDestination('First', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
   color: { r: 0, g: 0, b: 255 },
   textStyle: PdfTextStyle.bold});
// Destroy the document
document.destroy();

Returns PdfBookmark

add

Insert a new outline to the PDF document at specified index.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the PDF
let page: PdfPage = document.getPage(0);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Add a new outline to the PDF document
let bookmark: PdfBookmark = bookmarks.add('Introduction');
// Sets destination to the bookmark
bookmark.destination = new PdfDestination(page, {x: 10, 10});
// Destroy the document
document.destroy();
Parameter Type Description
title string The title of the outline.
index number The index to insert.

Returns PdfBookmark

add

Adds a new outline (bookmark) to the PDF document.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the PDF
let page: PdfPage = document.getPage(0);
// Add a new bookmark with destination
let bookmark: PdfBookmark = document.bookmarks.add('Introduction', 0, {
   destination: new PdfDestination(page, { x: 10, y: 10 }, {zoom: 1 }),
   namedDestination: new PdfNamedDestination('First', new PdfDestination(page, { x: 0, y: 10 }, {zoom: 1 })),
   color: { r: 0, g: 0, b: 255 },
   textStyle: PdfTextStyle.bold});
// Destroy the document
document.destroy();

Returns PdfBookmark

at

Gets the PdfBookmark at the specified index.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Get bookmark at the specified index
let bookmark: PdfBookmark = bookmarks.at(0) as PdfBookmark;
// Destroy the document
document.destroy();
Parameter Type Description
index number Bookmark index.

Returns PdfBookmark

clear

Removes all the bookmark from the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove all the bookmark from the collection.
bookmarks.clear();
// Get count after removal of all outlines.
let count: number = bookmarks.count;
// Destroy the document
document.destroy();

Returns void

contains

Gets the boolean flag indicating whether PdfBookmark is present or not.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Get the bookmark at the specified index
let bookmark: PdfBookmark = bookmarks.at(0) as PdfBookmark;
// Gets the boolean flag indicating whether `PdfBookmark` is present or not.
let isPresent: boolean = bookmarks.contains(bookmark);
// Destroy the document
document.destroy();
Parameter Type Description
outline PdfBookmark Bookmark.

Returns boolean

remove

Remove specified bookmark from the document.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the PDF
let page: PdfPage = document.getPage(0);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove specified bookmark from the document.
bookmarks.remove('Introduction');
// Sets destination to the bookmark
bookmark.destination = new PdfDestination(page, {x: 10, 10});
// Destroy the document
document.destroy();
Parameter Type Description
title string The title of the outline.

Returns void

remove

Remove the bookmark from the document at the specified index.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the PDF
let page: PdfPage = document.getPage(0);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove the bookmark from the document at the index 1.
bookmarks.remove(1);
// Sets destination to the bookmark
bookmark.destination = new PdfDestination(page, {x: 10, 10});
// Destroy the document
document.destroy();
Parameter Type Description
index number The index.

Returns void