how to add Hyperlink

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  how to add Hyperlink

DynamicPDF CoreSuite for .NET (v5) Forum

 May 23 2013 6:23 AM
Dear All,

I am using VS2005 .net to generate pdf . i want to add hyperlinks to navigate to sites in th epdf. is ther any options available.

Anupmadathil.
 May 23 2013 7:07 AM
Posted by a ceTe Software moderator
Hello,

Yes, you can add hyper links to the PDF document without any problem using our DynamicPDF Generator for .NET product. You will need to use the Link page element and set the UrlAction to it. You can refer documentation on Link page element here. You can also refer documentation on Action class here. Below is the sample code for it.
        
            string strUrl = "http://www.dynamicpdf.com";
            Font font = Font.Helvetica;
            float textWidth = font.GetTextWidth(strUrl, 10);
            Document document = new Document();
            Page page = new Page();
            document.Pages.Add(page);
            Label label=new Label(strUrl,100,100,textWidth,20,font,10,RgbColor.Blue);
            page.Elements.Add(label);
            UrlAction action = new UrlAction(strUrl);
            Link link = new Link(100, 100, textWidth, 20, action);
            page.Elements.Add(link);
            document.Draw(@"C:\MyDocument.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 12:09 AM.