Skip to main content

PdfGraphics.AddLinkToUri(RectangleF, Uri) Method

Adds a link to a URI at the specified page rectangle.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v25.1.Drawing.dll

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void AddLinkToUri(
    RectangleF linkArea,
    Uri uri
)

Parameters

Name Type Description
linkArea RectangleF

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.g., system rotation) are not taken into account when the AddLinkToUri method is called.

The following code snippet creates the PdfGraphics.AddLinkToUri method to create a link to a URI.

Add a Link to the Uri

using System;
using DevExpress.Pdf;
using System.Drawing;
using DevExpress.Drawing;

//...
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. 
    DXFont font = new DXFont("Arial", 10);

    DXSolidBrush blue = new DXSolidBrush(Color.Blue);
    graphics.DrawString("https://www.devexpress.com", font, blue, 310, 150);
}

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.

See Also