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.