Table of Contents
Using Links

EO.Pdf provides AcmLink object to create a clickable links. A link can navigate to another content, open a Web URL, or open a local file. The following code demonstrates how to create a link:

//Create the root content        
AcmContent root = new AcmContent();
        
//Create a link for text "Link Sample"        
AcmLink link = new AcmLink(new AcmText("Link Sample"));
root.Children.Add(link);

//Create a page break
root.Children.Add(new AcmPageBreak());

//Create some text on the second page
AcmText text = new AcmText("Some text on the second page");
root.Children.Add(text);

//Set the link to navigate to the text on the
//second page
link.TargetContent = text;

The above code creates a PDF file with two pages. The first page contains text "Link Sample". The second page contains text "some text on the second page". Clicking "Link Sample" would navigate to the second page.

Instead of setting the link's TargetContent, you can set the link's TargetUrl or TargetFile to open a Url or a file respectively. The following code set the link to open a Web URL:

//Link to an Url        
link.TargetUrl = "http://www.google.com";

The following code set the link to open notepad.exe:

//Link to a file
link.TargetFile = Path.Combine(
    Environment.SystemDirectory, "notepad.exe");