Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,211 changes: 552 additions & 659 deletions Document-Processing/PDF/PDF-Library/javascript/Annotations.md

Large diffs are not rendered by default.

256 changes: 121 additions & 135 deletions Document-Processing/PDF/PDF-Library/javascript/Bookmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,26 @@ Syncfusion<sup>&reg;</sup> PDF provides support to insert, remove and modify the
This example demonstrates how to add bookmarks to a PDF document using the `PdfBookmark` class. Bookmarks provide an easy way to navigate through different sections of a PDF file.

{% tabs %}
{% highlight c# tabtitle="TypeScript" %}

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

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
// Add page
let page: PdfPage = document.addPage();
// 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: 100, y: 200});
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}
// Create a new PDF document
let document: PdfDocument = new PdfDocument();
// Add page
let page: PdfPage = document.addPage();
// 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: 100, y: 200 });
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}
// Create a new PDF document
var document = new ej.pdf.PdfDocument();
// Add page
Expand All @@ -59,30 +57,28 @@ document.destroy();
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.

{% tabs %}
{% highlight c# tabtitle="TypeScript" %}

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

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get page
let page: PdfPage = document.getPage(0);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Gets the bookmark at the specified index
let bookmark: PdfBookmark = bookmarks.at(0) as PdfBookmark;
// Set the destination
bookmark.destination = new PdfDestination(page, {x: 100, y: 200});
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get page
let page: PdfPage = document.getPage(0);
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Gets the bookmark at the specified index
let bookmark: PdfBookmark = bookmarks.at(0) as PdfBookmark;
// Set the destination
bookmark.destination = new PdfDestination(page, { x: 100, y: 200 });
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}

{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data, password);
var document = new ej.pdf.PdfDocument(data);
// Get page
var page = document.getPage(0);
// Get the bookmarks
Expand All @@ -104,30 +100,28 @@ document.destroy();
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.

{% tabs %}
{% highlight c# tabtitle="TypeScript" %}

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

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Add a new outline to the PDF document
let bookmark: PdfBookmark = bookmarks.add('Introduction', 1);
// Sets destination to the bookmark
bookmark.destination = new PdfDestination(page, {x: 100, y: 200});
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Add a new outline to the PDF document
let bookmark: PdfBookmark = bookmarks.add('Introduction', 1);
// Sets destination to the bookmark
bookmark.destination = new PdfDestination(page, { x: 100, y: 200 });
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data, password);
var document = new ej.pdf.PdfDocument(data);
// Get the first page
var page = document.getPage(0);
// Get the bookmarks
Expand All @@ -148,28 +142,26 @@ document.destroy();

This example demonstrates how to remove bookmarks from an existing PDF document using the `PdfBookmark` class.
{% tabs %}
{% highlight c# tabtitle="TypeScript" %}

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

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove specified bookmark from the document.
bookmarks.remove('Introduction');
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfPage, PdfBookmarkBase} from '@syncfusion/ej2-pdf';

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove specified bookmark from the document.
bookmarks.remove('Introduction');
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data, password);
var document = new ej.pdf.PdfDocument(data);
// Get the first page
var page = document.getPage(0);
// Get the bookmarks
Expand All @@ -189,28 +181,26 @@ document.destroy();
This example demonstrates how to remove bookmarks from the document at the specific index using the `PdfBookmark` class.

{% tabs %}
{% highlight c# tabtitle="TypeScript" %}

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

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove the bookmark from the document at the index 1.
bookmarks.remove(1);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfPage, PdfBookmarkBase, PdfDestination} from '@syncfusion/ej2-pdf';

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get the first page
let page: PdfPage = document.getPage(0) as PdfPage;
// Get the bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Remove the bookmark from the document at the index 1.
bookmarks.remove(1);
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data, password);
var document = new ej.pdf.PdfDocument(data);
// Get the first page
var page = document.getPage(0);
// Get the bookmarks
Expand All @@ -230,28 +220,26 @@ document.destroy();
This example demonstrates how to removes all the bookmarks from the collection using the `PdfBookmark` class.

{% tabs %}
{% highlight c# tabtitle="TypeScript" %}

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

// 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;
// Save the document
document.save('Output.pdf');
// Destroy the document
document.destroy();
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfPage, PdfBookmarkBase} from '@syncfusion/ej2-pdf';

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// 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;
// Save the document
document.save('Output.pdf');
// Destroy the document
document.destroy();

{% endhighlight %}
{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data, password);
var document = new ej.pdf.PdfDocument(data);
// Get the bookmarks
var bookmarks = document.bookmarks;
// Remove all the bookmarks from the collection
Expand All @@ -271,26 +259,24 @@ document.destroy();
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.

{% tabs %}
{% highlight c# tabtitle="TypeScript" %}
{% highlight javascript tabtitle="TypeScript" %}
import {PdfDocument, PdfBookmarkBase} from '@syncfusion/ej2-pdf';

import {PdfDocument, PdfBookmarkBase} from '@syncfusion/ej2-pdf';

// 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 pageIndex: number = bookmarks.destination.pageIndex;
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get bookmarks
let bookmarks: PdfBookmarkBase = document.bookmarks;
// Get bookmark at the specified index
let pageIndex: number = bookmarks.destination.pageIndex;
// Save the document
document.save('Output.pdf');
// Close the document
document.destroy();

{% endhighlight %}
{% highlight c# tabtitle="JavaScript" %}

{% highlight javascript tabtitle="JavaScript" %}
// Load an existing PDF document
var document = new ej.pdf.PdfDocument(data, password);
var document = new ej.pdf.PdfDocument(data);
// Get bookmarks
var bookmarks = document.bookmarks;
// Get the first bookmark (or any specific one)
Expand Down
Loading