Skip to content

Commit 30b02ef

Browse files
committed
994201-dev: Added proper code example and verified.
1 parent ed536a5 commit 30b02ef

File tree

12 files changed

+660
-331
lines changed

12 files changed

+660
-331
lines changed

Document-Processing/PDF/PDF-Library/javascript/Annotations.md

Lines changed: 261 additions & 80 deletions
Large diffs are not rendered by default.

Document-Processing/PDF/PDF-Library/javascript/Bookmarks.md

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ This example demonstrates how to add bookmarks to a PDF document using the `PdfB
1616
{% tabs %}
1717
{% highlight c# tabtitle="TypeScript" %}
1818

19-
import {PdfDocument, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';
19+
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';
2020

2121
// Create a new PDF document
2222
let document: PdfDocument = new PdfDocument();
23+
// Add page
24+
let page: PdfPage = document.addPage();
2325
// Get the bookmarks
2426
let bookmarks: PdfBookmarkBase = document.bookmarks;
2527
// Add a new outline to the PDF document
@@ -41,10 +43,12 @@ This example demonstrates how to add bookmarks to an existing PDF document using
4143
{% tabs %}
4244
{% highlight c# tabtitle="TypeScript" %}
4345

44-
import {PdfDocument, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';
46+
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';
4547

4648
// Load an existing PDF document
4749
let document: PdfDocument = new PdfDocument(data, password);
50+
// Get page
51+
let page: PdfPage = document.getPage(0);
4852
// Get the bookmarks
4953
let bookmarks: PdfBookmarkBase = document.bookmarks;
5054
// Gets the bookmark at the specified index
@@ -75,7 +79,7 @@ This example demonstrates how to insert bookmarks at a specific position in an e
7579
// Get the bookmarks
7680
let bookmarks: PdfBookmarkBase = document.bookmarks;
7781
// Add a new outline to the PDF document
78-
let bookmark: PdfBookmark = bookmarks.add('Introduction');
82+
let bookmark: PdfBookmark = bookmarks.add('Introduction', 1);
7983
// Sets destination to the bookmark
8084
bookmark.destination = new PdfDestination(page, {x: 100, y: 200});
8185
// Save the document
@@ -88,8 +92,7 @@ This example demonstrates how to insert bookmarks at a specific position in an e
8892

8993
## Removing Bookmarks from an existing PDF
9094

91-
This example demonstrates how to remove bookmarks from an existing PDF document using the `PdfBookmark` class. Removing bookmarks helps clean up unnecessary navigation links.
92-
95+
This example demonstrates how to remove bookmarks from an existing PDF document using the `PdfBookmark` class.
9396
{% tabs %}
9497
{% highlight c# tabtitle="TypeScript" %}
9598

@@ -111,6 +114,58 @@ This example demonstrates how to remove bookmarks from an existing PDF document
111114
{% endhighlight %}
112115
{% endtabs %}
113116

117+
## Removing Bookmark from the document at the specified index
118+
119+
This example demonstrates how to remove bookmarks from the document at the specific index using the `PdfBookmark` class.
120+
121+
{% tabs %}
122+
{% highlight c# tabtitle="TypeScript" %}
123+
124+
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';
125+
126+
// Load an existing PDF document
127+
let document: PdfDocument = new PdfDocument(data, password);
128+
// Get the first page
129+
let page: PdfPage = document.getPage(0) as PdfPage;
130+
// Get the bookmarks
131+
let bookmarks: PdfBookmarkBase = document.bookmarks;
132+
// Remove the bookmark from the document at the index 1.
133+
bookmarks.remove(1);
134+
// Sets destination to the bookmark
135+
bookmark.destination = new PdfDestination(page, {x: 10, 10});
136+
// Save the document
137+
document.save('Output.pdf');
138+
// Close the document
139+
document.destroy();
140+
141+
{% endhighlight %}
142+
{% endtabs %}
143+
144+
## Removing all the Bookmark from the collection
145+
146+
This example demonstrates how to removes all the bookmarks from the collection using the `PdfBookmark` class.
147+
148+
{% tabs %}
149+
{% highlight c# tabtitle="TypeScript" %}
150+
151+
import {PdfDocument, PdfPage, PdfBookmarkBase} from '@syncfusion/ej2-pdf';
152+
153+
// Load an existing PDF document
154+
let document: PdfDocument = new PdfDocument(data, password);
155+
// Get the bookmarks
156+
let bookmarks: PdfBookmarkBase = document.bookmarks;
157+
// Remove all the bookmark from the collection.
158+
bookmarks.clear();
159+
// Get count after removal of all outlines.
160+
let count: number = bookmarks.count;
161+
// Save the document
162+
document.save('Output.pdf');
163+
// Destroy the document
164+
document.destroy();
165+
166+
{% endhighlight %}
167+
{% endtabs %}
168+
114169
## Bookmark page index in an existing PDF document
115170

116171
This example demonstrates how to retrieve the page index associated with a bookmark in an existing PDF document using the `PdfBookmark` class. This helps identify the exact location of the bookmark.
@@ -125,7 +180,7 @@ This example demonstrates how to retrieve the page index associated with a bookm
125180
// Get bookmarks
126181
let bookmarks: PdfBookmarkBase = document.bookmarks;
127182
// Get bookmark at the specified index
128-
let bookmark: PdfBookmark = bookmarks.at(0) as PdfBookmark;
183+
let pageIndex: number = bookmarks.destination.pageIndex;
129184
// Save the document
130185
document.save('Output.pdf');
131186
// Close the document

0 commit comments

Comments
 (0)