[]
Adds a hyperlink to the current page.
public void AddLink(string url, RectangleF rc)
Type | Name | Description |
---|---|---|
string | url | Link destination (can be a Url, a file name, or a local link destination). |
RectangleF | rc | Area on the page that will behave as a link (expressed in points, from the top-left corner of the page). |
Adds a hyperlink to the document.
public void AddLink(string url, int page, RectangleF rc)
Type | Name | Description |
---|---|---|
string | url | Link destination (can be a Url, a file name, or a local link destination). |
int | page | Index of the page that contains the hyperlink |
RectangleF | rc | Area on the page that will behave as a link (expressed in points, from the top-left corner of the page). |
<p>Hyperlinks can be external (Urls and file names) or local (other locations within the same document).</p>
<p>Local links are useful when you want to implement some type of cross-referencing within the document, such
as a table of contents or an index. Local links are identical to regular hyperlinks, except for two things:
1) The url
parameter must start with a "#", and
2) You must specify the target location for the link using the AddTarget method.
Note that the AddLink method does not add any visible content to the page, so you will usually need another command along with AddLink to specify some text or an image that the user can see, as the example below demonstrates.
The code below adds a string that says "Visit site" and a link that takes the user to the ComponentOne home page:
Rect rc = new Rect(50, 50, 100, 15); // RectangleF
Font font = new Font("Arial", 10, PdfFontStyle.Underline); // FontStyle
_c1pdf.AddLink("http://www.google.com", rc);
_c1pdf.DrawString("Visit site", font, Color.Blue, rc); // Brushes.Blue