Link
The Link class inherits the abstract Annotation class. Link annotations represent either a hypertext link to a destination elsewhere in the document or an action to be performed. For this reason, there are two separate constructors in the Link class - one requiring a Destination object and one requiring an Action object.
Link exposes the following properties:
| Property | Description |
|---|---|
Destination | A destination to be displayed when the annotation is activated. See Example 1 below. |
NamedDestination | A named destination associated with the link. |
Action | An action to be performed when the annotation is activated. See Example 2 below. |
Example 1: Add link to destination
RadFixedDocument document = new RadFixedDocument();
RadFixedPage page = new RadFixedPage();
document.Pages.Add(page);
Location destination = new Location
{
Left = 225,
Top = 500,
Zoom = 1
};
Link linkWithDestination = new Link(destination);
page.Annotations.Add(linkWithDestination);
Example 2: Add link with action
GoToAction action = new GoToAction
{
Destination = destination
};
Link linkWithAction = new Link(action);
page.Annotations.Add(linkWithAction);
In Example 2, the action object should be from the
Telerik.Windows.Documents.Fixed.Model.Actions.Actiontype.
Destination
The abstract Destination class defines a particular view of a document, consisting of the following items:
- The page, which needs to be displayed.
- The location on that page.
- The magnification (zoom) factor, which should be used when displaying the page.
The Destination class itself only exposes a Page property specifying the page of the destination. The other properties of the view are determined by the classes that inherit Destination:
| Class | Description |
|---|---|
Location | Exposes Left, Top, and Zoom properties. Displays the specified page positioned with (Left, Top) at the upper-left corner of the window, magnified by Zoom. |
PageFit | Displays the specified page magnified just enough to fit the entire page within the window both horizontally and vertically. |
PageHorizontalFit | Exposes Top property. Displays the specified page with Top positioned at the top edge of the window, magnified to fit the entire page width. |
PageVerticalFit | Exposes Left property. Displays the specified page with Left at the left edge of the window, magnified to fit the entire page height. |
RectangleFit | Exposes Left, Top, Right, and Bottom properties. Displays the specified page magnified to fit the rectangle defined by those coordinates. |
BoundingRectangleFit | Displays the specified page magnified to fit its bounding box within the window. |
BoundingRectangleHorizontalFit | Exposes Top property. Displays the specified page with Top at the top edge, magnified to fit the entire width of its bounding box. |
BoundingRectangleVerticalFit | Exposes Left property. Displays the specified page with Left at the left edge, magnified to fit the entire height of its bounding box. |
Example 3 shows how you can create a Location object, associate it with a Link and add it to a RadFixedPage.
Example 3: Add link with location
RadFixedPage secondPage = new RadFixedPage();
document.Pages.Add(secondPage);
Location location = new Location();
location.Left = 225;
location.Top = 500;
location.Zoom = 4;
location.Page = secondPage;
RadFixedPage firstPage = document.Pages.AddPage();
var link = firstPage.Annotations.AddLink(location);
link.Rect = new Rect(10, 10, 50, 50);
Action
Example 4 demonstrates how to create an action of type GoToAction, associate it with a Link and add it to a RadFixedPage. The location object can be of type Location like the one in Example 3.
Example 4: Add link with action
GoToAction goToAction = new GoToAction();
goToAction.Destination = location;
var goToLink = firstPage.Annotations.AddLink(goToAction);
goToLink.Rect = new Rect(10, 10, 50, 50);
UriAction uriAction = new UriAction();
uriAction.Uri = new Uri(@"http://www.telerik.com");
var uriLink = firstPage.Annotations.AddLink(uriAction);
uriLink.Rect = new Rect(70, 10, 50, 50);