PDFPAGE_SetLinkToPage
IPDFDocument3 :: PDF page methods

See Also Example
Collapse All

This method creates a hyperlink in a PDF document.

Syntax

HRESULT PDFPAGE_SetLinkToPage (
DOUBLE left,
DOUBLE bottom,
DOUBLE right,
DOUBLE top,
LONG pageIndex,
LONG topOffset
)
Parameters
left
X coordinate of the top-left corner of the bounding rectangle.

bottom
Y coordinate of the bottom-righ corner of the bounding rectangle.

right
X coordinate of the bottom-righ corner of the bounding rectangle.

top
Y coordinate of the top-left corner of the bounding rectangle.

pageIndex
Index (zero-based) of the existing page

topOffset
Offset from the top of the page.

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

This method places an active hyperlink area for the rectangle with left-top corner at (left, top) and right-bottom corner at (right, bottom). The destination is a page in the current PDF document with the pageIndex index. The topOffset parameter depends on the location of the display window for that page, offset from top of the page.

Equivalent in new interface: IPDFDocument4::AddLinkToPage.

Example

Linking to a Page

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.BeginDoc;
txt := 'Link to page''s bottom.';
for i := 1 to 3 do
begin
    PDF.PDFPAGE_SetActiveFont('Helvetica', false, false, false, false, 12.0, 0);
    r := 100 + PDF.PDFPAGE_GetTextWidth(txt);
    b := 100 + PDF.PDFPAGE_GetTextHeight(txt);
    PDF.PDFPAGE_TextOut(100, 100, 0.0, txt);
    PDF.PDFPAGE_Rectangle(100, 100, r, b);
    PDF.PDFPAGE_Stroke;
    PDF.PDFPAGE_SetLinkToPage(100, b, r, 100, PDF.PageNumber, 20);
    if i < 2 then do
      PDF.NewPage;
end;
PDF.EndDoc;
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->BeginDoc();
string txt = "Link to page's bottom.";
for (int i = 0; i < 3; i++)
{
    PDF->PDFPAGE_SetActiveFont("Helvetica", FALSE, FALSE, FALSE, FALSE, 12.0, 0);
    DOUBLE r = 100 + PDF->PDFPAGE_GetTextWidth(txt);
    DOUBLE b = 100 + PDF->PDFPAGE_GetTextHeight(txt);
    PDF->PDFPAGE_TextOut(100, 100, 0.0, txt);
    PDF->PDFPAGE_Rectangle(100, 100, r, b);
    PDF->PDFPAGE_Stroke();
    PDF->PDFPAGE_SetLinkToPage(100, b, r, 100, PDF.PageNumber, 20);
    if (i < 2)
      PDF->NewPage();
}
PDF->EndDoc();
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.BeginDoc();
string txt = "Link to page's bottom.";
for (int i = 0; i < 3; i++)
{
    PDF.PDFPAGE_SetActiveFont("Helvetica", false, false, false, false, 12.0, 0);
    double r = 100 + PDF.PDFPAGE_GetTextWidth(txt);
    double b = 100 + PDF.PDFPAGE_GetTextHeight(txt);
    PDF.PDFPAGE_TextOut(100, 100, 0.0, txt);
    PDF.PDFPAGE_Rectangle(100, 100, r, b);
    PDF.PDFPAGE_Stroke();
    PDF.PDFPAGE_SetLinkToPage(100, b, r, 100, PDF.PageNumber, 20);
    if (i < 2)
      PDF.NewPage();
}
PDF.EndDoc();
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.BeginDoc
txt = "Link to page's bottom."
For i=1 To 3
    PDF.PDFPAGE_SetActiveFont "Helvetica", False, False, False, False, 12.0, 0
    r = 100 + PDF.PDFPAGE_GetTextWidth(txt)
    b = 100 + PDF.PDFPAGE_GetTextHeight(txt)
    PDF.PDFPAGE_TextOut 100, 100, 0.0, txt
    PDF.PDFPAGE_Rectangle 100, 100, r, b
    PDF.PDFPAGE_Stroke
    PDF.PDFPAGE_SetLinkToPage 100, b, r, 100, PDF.PageNumber, 20
    If i<3 Then PDF.NewPage
Next
PDF.EndDoc

See Also

Reference