PdfGraphics.AddLinkToUri(RectangleF, Uri) Method
Adds a link to a URI at the specified page rectangle.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
#Declaration
public void AddLinkToUri(
RectangleF linkArea,
Uri uri
)
#Parameters
Name | Type | Description |
---|---|---|
link |
Rectangle |
A page area (in the world coordinate system) where you can add a link. |
uri | Uri | A Uri object that is the link URI. |
#Remarks
This method specifies the page area on which you can click to refer to the URI defined by the uri parameter.
To draw a link on the PDF page, use one of the following methods:
- PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackground
- These methods allow you to draw content on an existing page.
- PdfDocumentProcessor.RenderNewPage
- Draws content on a new page.
Note
Coordinate system transformations (e.Add
method is called.
The code sample below demonstrates how to use the PdfGraphics.AddLinkToUri
method to create a link to a URI.
using System;
using DevExpress.Pdf;
using System.Drawing;
namespace AddLinkToUri {
class Program {
static void Main(string[] args) {
using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
// Create an empty document.
processor.CreateEmptyDocument("..\\..\\Result.pdf");
// Create and draw graphics.
using (PdfGraphics graphics = processor.CreateGraphics()) {
DrawGraphics(graphics);
// Create a link to URI specifying link area and URI.
graphics.AddLinkToUri(new RectangleF(310, 150, 180, 15), new Uri("https://www.devexpress.com"));
// Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics);
}
}
}
static void DrawGraphics(PdfGraphics graphics) {
// Draw a text line on the page.
using (Font font = new Font("Arial", 10)) {
SolidBrush blue = (SolidBrush)Brushes.Blue;
graphics.DrawString("https://www.devexpress.com", font, blue, 310, 150);
}
}
}
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddLinkToUri(RectangleF, Uri) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.