You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Library/javascript/Bookmarks.md
+8-45Lines changed: 8 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ document.destroy();
34
34
35
35
{% endhighlight %}
36
36
{% highlight javascript tabtitle="JavaScript" %}
37
+
37
38
// Create a new PDF document
38
39
var document = new ej.pdf.PdfDocument();
39
40
// Add page
@@ -52,49 +53,6 @@ document.destroy();
52
53
{% endhighlight %}
53
54
{% endtabs %}
54
55
55
-
## Adding Bookmarks in an existing PDF document
56
-
57
-
This example demonstrates how to add bookmarks to an existing PDF document using the `PdfBookmark` class. This allows you to enhance navigation in already created PDF document.
58
-
59
-
{% tabs %}
60
-
{% highlight javascript tabtitle="TypeScript" %}
61
-
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';
62
-
63
-
// Load an existing PDF document
64
-
let document: PdfDocument = new PdfDocument(data);
65
-
// Get page
66
-
let page: PdfPage = document.getPage(0);
67
-
// Get the bookmarks
68
-
let bookmarks: PdfBookmarkBase = document.bookmarks;
69
-
// Gets the bookmark at the specified index
70
-
let bookmark: PdfBookmark = bookmarks.at(0) as PdfBookmark;
71
-
// Set the destination
72
-
bookmark.destination = new PdfDestination(page, { x: 100, y: 200 });
73
-
// Save the document
74
-
document.save('Output.pdf');
75
-
// Close the document
76
-
document.destroy();
77
-
78
-
{% endhighlight %}
79
-
{% highlight javascript tabtitle="JavaScript" %}
80
-
// Load an existing PDF document
81
-
var document = new ej.pdf.PdfDocument(data);
82
-
// Get page
83
-
var page = document.getPage(0);
84
-
// Get the bookmarks
85
-
var bookmarks = document.bookmarks;
86
-
// Get the bookmark at the specified index
87
-
var bookmark = bookmarks.at(0);
88
-
// Set the destination
89
-
bookmark.destination = new ej.pdf.PdfDestination(page, { x: 100, y: 200 });
90
-
// Save the document
91
-
document.save('Output.pdf');
92
-
// Close the document
93
-
document.destroy();
94
-
95
-
{% endhighlight %}
96
-
{% endtabs %}
97
-
98
56
## Inserting Bookmarks in an existing PDF
99
57
100
58
This example demonstrates how to insert bookmarks at a specific position in an existing PDF document using the `PdfBookmark` class. This feature allows precise control over bookmark order.
@@ -109,7 +67,7 @@ let document: PdfDocument = new PdfDocument(data);
109
67
let page: PdfPage = document.getPage(0) as PdfPage;
110
68
// Get the bookmarks
111
69
let bookmarks: PdfBookmarkBase = document.bookmarks;
112
-
// Add a new outline to the PDF document
70
+
// Add a new bookmark at the specified page index
113
71
let bookmark: PdfBookmark = bookmarks.add('Introduction', 1);
114
72
// Sets destination to the bookmark
115
73
bookmark.destination = new PdfDestination(page, { x: 100, y: 200 });
@@ -120,13 +78,14 @@ document.destroy();
120
78
121
79
{% endhighlight %}
122
80
{% highlight javascript tabtitle="JavaScript" %}
81
+
123
82
// Load an existing PDF document
124
83
var document = new ej.pdf.PdfDocument(data);
125
84
// Get the first page
126
85
var page = document.getPage(0);
127
86
// Get the bookmarks
128
87
var bookmarks = document.bookmarks;
129
-
// Add a new outline to the PDF document
88
+
// Add a new bookmark at the specified page index
130
89
var bookmark = bookmarks.add('Introduction', 1);
131
90
// Set destination to the bookmark
132
91
bookmark.destination = new ej.pdf.PdfDestination(page, { x: 100, y: 200 });
0 commit comments