AddLinkToPage
IPDFDocument4 :: Page Operations :: Common

See Also Example
Collapse All

This method adds a hyperlink to a PDF document's page.

Syntax

HRESULT AddLinkToPage (
FLOAT left,
FLOAT top,
FLOAT right,
FLOAT bottom,
LONG pageNumber,
FLOAT topOffset
)
Parameters
left
X coordinate of the top-left corner of the bounding rectangle

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

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

bottom
Y coordinate of the bottom-right corner of the bounding rectangle

pageNumber
Number of the PDF document's page to which the link connects. The page number is zero-based.

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.

Example

Adding a Link to a Page

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.ShowTextAt(50, 50, 'It is a page #1.');
PDF.ShowTextAt(50, 60, 'Go to page #2.');
PDF.AddLinkToPage 50, 60, 100, 70, 1, 0);
PDF.NewPage;
PDF.ShowTextAt(50, 50, 'It is a page #2.');
PDF.ShowTextAt(50, 60, 'Go to page #1.');
PDF.AddLinkToPage(50, 60, 100, 70, 0, 0);
PDF.ShowTextAt(50, 70, 'Go to page #3.');
PDF.AddLinkToPage(50, 70, 100, 80, 2, 0);
PDF.NewPage;
PDF.ShowTextAt(50, 50, 'It is a page #3.');
PDF.ShowTextAt(50, 60, 'Go to page #2.');
PDF.AddLinkToPage(50, 60, 100, 70, 1, 0);
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->ShowTextAt(50, 50, "It is a page #1.");
PDF->ShowTextAt(50, 60, "Go to page #2.");
PDF->AddLinkToPage 50, 60, 100, 70, 1, 0);
PDF->NewPage();
PDF->ShowTextAt(50, 50, "It is a page #2.");
PDF->ShowTextAt(50, 60, "Go to page #1.");
PDF->AddLinkToPage(50, 60, 100, 70, 0, 0);
PDF->ShowTextAt(50, 70, "Go to page #3.");
PDF->AddLinkToPage(50, 70, 100, 80, 2, 0);
PDF->NewPage();
PDF->ShowTextAt(50, 50, "It is a page #3.");
PDF->ShowTextAt(50, 60, "Go to page #2.");
PDF->AddLinkToPage(50, 60, 100, 70, 1, 0);
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.ShowTextAt(50, 50, "It is a page #1.");
PDF.ShowTextAt(50, 60, "Go to page #2.");
PDF.AddLinkToPage 50, 60, 100, 70, 1, 0);
PDF.NewPage();
PDF.ShowTextAt(50, 50, "It is a page #2.");
PDF.ShowTextAt(50, 60, "Go to page #1.");
PDF.AddLinkToPage(50, 60, 100, 70, 0, 0);
PDF.ShowTextAt(50, 70, "Go to page #3.");
PDF.AddLinkToPage(50, 70, 100, 80, 2, 0);
PDF.NewPage();
PDF.ShowTextAt(50, 50, "It is a page #3.");
PDF.ShowTextAt(50, 60, "Go to page #2.");
PDF.AddLinkToPage(50, 60, 100, 70, 1, 0);
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.ShowTextAt 50, 50, "It is a page #1."
PDF.ShowTextAt 50, 60, "Go to page #2."
PDF.AddLinkToPage 50, 60, 100, 70, 1, 0
PDF.NewPage
PDF.ShowTextAt 50, 50, "It is a page #2."
PDF.ShowTextAt 50, 60, "Go to page #1."
PDF.AddLinkToPage 50, 60, 100, 70, 0, 0
PDF.ShowTextAt 50, 70, "Go to page #3."
PDF.AddLinkToPage 50, 70, 100, 80, 2, 0
PDF.NewPage
PDF.ShowTextAt 50, 50, "It is a page #3."
PDF.ShowTextAt 50, 60, "Go to page #2."
PDF.AddLinkToPage 50, 60, 100, 70, 1, 0
PDF.SaveToFile "test.pdf", true

See Also

Reference