Named Destinations
Named destinations are destinations in a document that you can refer to indirectly through a name object or a byte string.
NamedDestination Class
The NamedDestination class represents named destinations in PDF documents. It exposes the following properties:
| Property | Description |
|---|---|
Name | Gets or sets the destination name. Changing this property also affects the name of the named destination inside the document collection. |
Destination | Of type Destination, determines the actual destination this named destination points to. |
GoToAction | Gets or sets the GoToAction of the named destination. |
NamedDestinations Collection
The NamedDestinations collection is exposed by RadFixedDocument and allows you to add, remove, modify, and iterate the NamedDestination objects in a PDF document. This collection implements IEnumerable and you can obtain a NamedDestination by its name.
Create
You can create NamedDestination objects through the Add() method of the NamedDestinations collection exposed by RadFixedDocument.
Example 1: Create NamedDestination with Destination of type Link
this.pdfDocument.NamedDestinations.Add("myNamedDest", new Location() { Page = this.pdfDocument.Pages[0], Left = 50, Top = 150 });
Remove
You can remove a named destination as you do with any item in a collection.
Example 2: Remove NamedDestination
this.pdfDocument.NamedDestinations.Remove("myNamedDest");
Rename
In addition to the Name property of the NamedDestination class, which has a setter, you can use the Rename() method of the RadFixedDocument.NamedDestinations collection.
Example 3: Rename NamedDestination
this.pdfDocument.NamedDestinations.Rename("myNamedDest", "Chapter1");
Check If a Name Exists
The NamedDestinations collection provides the ContainsName() method. Use it to check whether a name is already applied to a NamedDestination or whether the NamedDestination you are searching for exists.
Example 4: Check if a NamedDestination already exists
this.pdfDocument.NamedDestinations.ContainsName("myNamedDest");