PDF for UWP | ComponentOne
C1.Xaml.Pdf Namespace / C1PdfDocument Class / AddLink Method / AddLink(String,Int32,Rect) Method
Link destination (can be a Url, a file name, or a local link destination).
Index of the page that contains the hyperlink
Area on the page that will behave as a link (expressed in points, from the top-left corner of the page).
Example

In This Topic
    AddLink(String,Int32,Rect) Method
    In This Topic
    Adds a hyperlink to the document.
    Syntax
    'Declaration
     
    
    Public Overloads Sub AddLink( _
       ByVal url As String, _
       ByVal page As Integer, _
       ByVal rc As Rect _
    ) 
    public void AddLink( 
       string url,
       int page,
       Rect rc
    )

    Parameters

    url
    Link destination (can be a Url, a file name, or a local link destination).
    page
    Index of the page that contains the hyperlink
    rc
    Area on the page that will behave as a link (expressed in points, from the top-left corner of the page).
    Remarks

    Hyperlinks can be external (Urls and file names) or local (other locations within the same document).

    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.

    Example
    The code below adds a string that says "Visit GrapeCity" 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.grapecity.com", rc);
    _c1pdf.DrawString("Visit GrapeCity", font, Color.Blue, rc);  // Brushes.Blue
    See Also