PdfPageFacade.AddLinkAnnotation(PdfRectangle, String) Method
In This Article
Creates a link annotation in the specified rectangle on the page.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
public PdfLinkAnnotationFacade AddLinkAnnotation(
PdfRectangle rect,
string uri
)
#Parameters
Name | Type | Description |
---|---|---|
rect | Pdf |
A page area to add a link annotation. |
uri | String | A URI associated with the annotation. |
#Returns
Type | Description |
---|---|
Pdf |
An object that contains link annotation properties. |
#Example
The code sample below creates an annotation linked to a URI string:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Find the target phrase in the document
string linkText = "Evaluation";
PdfTextSearchResults linkSearchResults = processor.FindText(linkText);
if (linkSearchResults.Status == PdfTextSearchStatus.Found)
{
PdfRectangle linkRectangle = linkSearchResults.Rectangles[0].BoundingRectangle;
string linkUri = "https://community.devexpress.com/blogs/";
// Add a link annotation to the found text
PdfLinkAnnotationFacade uriAnnotation = page.AddLinkAnnotation(linkRectangle, linkUri);
uriAnnotation.Name = "link1";
uriAnnotation.HighlightMode = PdfAnnotationHighlightingMode.Push;
}
processor.SaveDocument("..\\..\\Result.pdf");
}
See Also