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.v24.2.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
#Declaration
public void AddLinkToPage(
RectangleF linkArea,
int pageNumber,
float destinationX,
float destinationY
)
#Parameters
Name | Type | Description |
---|---|---|
link |
Rectangle |
A page area (in the world coordinate system) where you can add a link. |
page |
Int32 | The page number. |
destination |
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. |
destination |
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.
Note
Coordinate system transformations (e.Add
method is called.
The code sample below adds a link that refers to the point with coordinates (168, 230) from the second document page.
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 and draw graphics.
using (PdfGraphics graphics = processor.CreateGraphics()) {
DrawGraphics(graphics);
// Create a link to a page specifying link area, the page number and X, Y destinations.
graphics.AddLinkToPage(new RectangleF(180, 160, 480, 30), 1, 168, 230);
// Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics);
}
}
}
static void DrawGraphics(PdfGraphics graphics) {
// Draw a text line on the page.
SolidBrush black = (SolidBrush)Brushes.Black;
using (Font font = new Font("Times New Roman", 32, FontStyle.Bold)) {
graphics.DrawString("PDF Document Processor", font, black, 180, 150);
}
}
}
}
#Related GitHub Examples
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.