PdfGraphics.AddLinkToPage(RectangleF, Int32, Single, Single, Single) Method
Adds a link that refers to the document page with the specified number. Allows you to set the page point positioned at the top left corner of the document window, and zoom factor.
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,
float zoom
)
#Parameters
Name | Type | Description |
---|---|---|
link |
Rectangle |
A page area (in world coordinate system) where you can add a link. |
page |
Int32 | The page number. |
destination |
Single | The horizontal coordinate of a page point (in the world coordinate system) positioned at the top left corner of the document window. |
destination |
Single | The vertical coordinate of a page point (in the world coordinate system) positioned at the top left corner of the document window. |
zoom | Single | The zoom factor by which the document is scaled after you click a link. |
#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 number of the target page. After you click the added link, the target page is scaled by the specified zoom factor.
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 second document page and scales this page by 300%.
using System;
using DevExpress.Pdf;
using System.Drawing;
//...
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Create an empty document.
processor.CreateEmptyDocument("..\\..\\Result.pdf");
// Create and draw graphics.
using (PdfGraphics graphics = processor.CreateGraphics())
{
// Draw a 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.
graphics.AddLinkToPage(new RectangleF(180, 160, 480, 30), 2, 168, 230, 3);
// Render a page with graphics.
processor.RenderNewPage(PdfPaperSize.Letter, graphics);
// Create the second document page to which the link refers.
processor.AddNewPage(PdfPaperSize.A4);
}
}