Create a hyperlink to a location in the current document

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v7)  /  Create a hyperlink to a location in the current document

DynamicPDF CoreSuite for .NET (v7) Forum

Hi Support Team,
I want to create bookmark on first page of document (not left of pdf bookmark section) like index page when user click on any specific bookmark then go to the corrosponding linked page.

So, is there any possibilities ?


Regards,
Niraj Pandey

Posted by a ceTe Software moderator

Hello Niraj,

Yes, you can add links to the first page of PDF so you can navigate to the desired page as per the destination set to the link. You will need to use the Link page element to do this. Please refer to the documentation on Link page element here. You will need to create Link class object and set the action to it using Action classes.  You can refer to the documentation on different action classes here. Below is the code sample for it.

            Document document = new Document();
            Page indexPage = new Page();
            document.Pages.Add(indexPage);
            //Add pages to the document.
            float xPosition=0;
            float yPosition =0;
            for (int i = 1; i < 10; i++)
            {
                Page page = new Page();
                document.Pages.Add(page);
                TextArea area = new TextArea("Page "+i, 100, 100, 100, 30);
                page.Elements.Add(area);

                // Add links to the index page
                Label linkLabel = new Label("Go To Page "+i, xPosition, yPosition, 100, 20,Font.Helvetica,10,RgbColor.Blue);
                // Set the action then create the link
                XYDestination action = new XYDestination(i+1,0, 0);
                Link link = new Link(xPosition, yPosition, 100, 20, action);
                // Add the label and the link to the page
                indexPage.Elements.Add(linkLabel);
                indexPage.Elements.Add(link);
                yPosition = yPosition + linkLabel.Height + 5;

            }
            document.Draw(@"C:\Temp\MyDocument.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 7:27 PM.