ComponentOne PDF for .NET
In This Topic
    HyperLinks
    In This Topic

    Among all the static content of a PDF, links are required to jump from one location to other location within the document or outside the document. Creating hyperlinks is one such way which not only helps in navigating through the content but also makes it interactive. Hyperlinks can be presented in different forms, like an image, text, or any type of visible element that, when clicked, redirects you to a specified url. 

    The C1PdfDocument class provides AddLink methods for adding hyperlinks to your PDF documents which takes the following two parameters:

    Note that the AddLink method does not add any visible content to the page, so you may need another command along with it to specify some text or an image that the user can see.

    To add a hyperlink in the page, use the following code. In this example, we have added a string that says "Visit Documentation Website" and linked it to the Mescius website.

    C#
    Copy Code
    pdf.DrawString("Visit the Documentation Website", font, Brushes.Black, rect);
    pdf.AddLink("https://developer.mescius.com/componentone/docs", rect);
    

    You can also add local links, which when clicked can take you to another location within the same PDF document. This type of link helps you to implement 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: