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
page_title: Annotations - WinForms PdfViewer Control
4
-
description: WinForms PdfViewer supports Link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address.
5
-
slug: winforms/pdfviewer/annotations
6
-
tags: annotations
7
-
published: True
8
-
position: 0
9
-
---
10
-
11
-
# Annotations
12
-
__RadPdfViewer__ supports link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. In addition, if there are links pointing to bookmarks in the same document, the view port will be scrolled to the destination specified in the link.
13
-
14
-
The current API includes the following members, which allow customization of the default behavior or implementing custom logic:
15
-
16
-
*__AnnotationClicked__ event of __RadPdfViewer__: This event is fired when you click on an annotation such as a hyperlink. It comes handy when you want to detect or even cancel the opening of a web page. The __AnnotationEventArgs__ contain the Annotation as property and the Link itself has information of its Action, i.e. if it is a UriAction. Handling the event in the following manner will not only show the Uri of each clicked link as the text of a MessageBox, but will also cancel the default behavior.
page_title: Annotations - WinForms PdfViewer Control
4
+
description: WinForms PdfViewer supports Link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address.
5
+
slug: winforms/pdfviewer/annotations
6
+
tags: annotations
7
+
published: True
8
+
position: 0
9
+
---
10
+
11
+
# Annotations
12
+
__RadPdfViewer__ supports link annotations, which means that if you open a PDF file that includes hyperlinks to absolute URIs, you can click them and have a window open, navigated to the respective address. In addition, if there are links pointing to bookmarks in the same document, the view port will be scrolled to the destination specified in the link.
13
+
14
+
The current API includes the following members, which allow customization of the default behavior or implementing custom logic:
15
+
16
+
*__AnnotationClicked__ event of __RadPdfViewer__: This event is fired when you click on an annotation such as a hyperlink. It comes handy when you want to detect or even cancel the opening of a web page. The __AnnotationEventArgs__ contain the Annotation as property and the Link itself has information of its Action, i.e. if it is a UriAction. Handling the event in the following manner will not only show the Uri of each clicked link as the text of a MessageBox, but will also cancel the default behavior.
@@ -52,18 +52,64 @@ Private Sub radPdfViewer1_AnnotationClicked(sender As Object, e As Telerik.Windo
52
52
MessageBox.Show(a.Uri.ToString())
53
53
e.Handled=True
54
54
EndSub
55
-
56
-
````
57
-
58
-
{{endregion}}
59
-
60
-
*__Annotations__ property of __RadFixedDocument__ – A collection which returns all annotations in the document. For example you can retrieve all links using the following code:
*__HyperlinkClicked__ event of RadPdfViewer: This event is similar to AnnotationClicked, but it is raised only when you click on the hyperlink type annotations. It allows you to cancel the navigation to the associated URI or to modify the click action. The HyperlinkClickedEventArgs gives access to the URL, which can be manually checked if it is trusted. The navigation can be canceled by either setting the __Handled__ property of the event args to _true_ or the __IsTrustedUrl__ property to _false_. Below is an example of using this event to prompt that the clicked hyperlink might be unsafe and provide the opportunity to cancel the navigation process upon receiving the end user confirmation:
e.Handled=true; MessageBoxResultResult=System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed", "Possible unsafe link", MessageBoxButton.YesNo, MessageBoxImage.Question);
DimResultAsMessageBoxResult=System.Windows.MessageBox.Show("You are about to open an executable file. Do you want to proceed","Possible unsafe link",MessageBoxButton.YesNo,MessageBoxImage.Question)
92
+
IfResult=MessageBoxResult.YesThen
93
+
Process.Start(NewProcessStartInfo()With{
94
+
.FileName=link,
95
+
.UseShellExecute=True
96
+
})
97
+
EndIf
98
+
EndIf
99
+
EndSub
100
+
101
+
````
102
+
103
+
{{endregion}}
104
+
105
+
106
+
*__Annotations__ property of __RadFixedDocument__ – A collection which returns all annotations in the document. For example you can retrieve all links using the following code:
@@ -88,18 +134,18 @@ Private Iterator Function GetAllLinks(document As Telerik.Windows.Documents.Fixe
88
134
EndIf
89
135
Next
90
136
EndFunction
91
-
92
-
````
93
-
94
-
{{endregion}}
95
-
96
-
The bookmarks in terms of “docx bookmarks” are not explicitly saved in PDF files. They are persisted only if there are Link annotations to them, so you can use the snippet below to retrieve all destinations that have links to them:
The bookmarks in terms of “docx bookmarks” are not explicitly saved in PDF files. They are persisted only if there are Link annotations to them, so you can use the snippet below to retrieve all destinations that have links to them:
@@ -124,38 +170,38 @@ Private Iterator Function GetAllBookmarks(document As Telerik.Windows.Documents.
124
170
EndIf
125
171
Next
126
172
EndFunction
127
-
128
-
````
129
-
130
-
{{endregion}}
131
-
132
-
In this way it would be possible to create some UI that contains all bookmarks. Then, you could implement the same action as the one being executed when a hyperlink is clicked, i.e. scroll the document to the specific place in the document where the destination of the link is placed. The following code can be used for this purpose – navigating to a specific destination:
In this way it would be possible to create some UI that contains all bookmarks. Then, you could implement the same action as the one being executed when a hyperlink is clicked, i.e. scroll the document to the specific place in the document where the destination of the link is placed. The following code can be used for this purpose – navigating to a specific destination:
0 commit comments