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

PdfGraphics.AddLinkToPage(RectangleF, Int32, Single, Single) Method

Adds a link that refers to the document page with the specified number. Allows you to set a page point positioned at the top left corner of the document window.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void AddLinkToPage(
    RectangleF linkArea,
    int pageNumber,
    float destinationX,
    float destinationY
)

Parameters

Name Type Description
linkArea RectangleF

A page area (in the world coordinate system) where you can add a link.

pageNumber Int32

The page number.

destinationX Single

The horizontal coordinate of a target page point (in the world coordinate system) that is positioned at the top left corner of the document window.

destinationY Single

The vertical coordinate of a target page point (in the world coordinate system) that is positioned at the top left corner of the document window.

Remarks

This method specifies the page area on which you can click to refer to a specific page location defined by the destinationX and destinationY parameters. The pageNumber parameter specifies the target page number.

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 adds a link that refers to the point with coordinates (168, 230) from the second document page.

View Example

using DevExpress.Pdf;
using System.Drawing;


namespace AddLinkToPage
{
    class Program
    {
        static void Main(string[] args)
        {            

            using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
            {
                // Create an empty document.
                processor.CreateEmptyDocument("..\\..\\Result.pdf");

                // Create a PdfGraphics class instance.
                using (PdfGraphics graphics = processor.CreateGraphics())
                {
                    // Draw link text.
                    SolidBrush black = (SolidBrush)Brushes.Black;
                    using (Font font = new Font("Times New Roman", 32, FontStyle.Bold))
                    {
                        graphics.DrawString("PDF Document API", font, black, 180, 150);
                    }

                    // Create a link to the second document page.
                    // Specify the page destination to which the link should refer.
                    graphics.AddLinkToPage(new RectangleF(180, 160, 480, 30), 2, 168, 230);

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

                    // Create the second document page to which the link navigates.
                    processor.AddNewPage(PdfPaperSize.A4);
                }
            }
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddLinkToPage(RectangleF, Int32, Single, Single) 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