Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

PdfGraphics.AddLinkToUri(RectangleF, Uri) Method

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

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v21.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.

The code sample below demonstrates how to use the PdfGraphics.AddLinkToUri method to create a link to a URI.

Add a Link to the Uri

View Example

using DevExpress.Pdf;
using System;
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())
                {
                    using (Font font = new Font("Arial", 34))
                    {
                        SolidBrush blue = (SolidBrush)Brushes.Blue;

                        // Calculate the link size
                        SizeF stringSize = graphics.MeasureString("https://www.devexpress.com", font);
                        RectangleF stringRect = new RectangleF(100, 150, stringSize.Width, stringSize.Height);

                        // Draw a link text. 
                        graphics.DrawString("https://www.devexpress.com", font, blue, stringRect);

                        // Create a link to a URI at the specified page area.
                        graphics.AddLinkToUri(stringRect, new Uri("https://www.devexpress.com"));
                    }

                    // Render a page with graphics.
                    processor.RenderNewPage(PdfPaperSize.Letter, graphics);
                }
            }

        }
    }
}

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