We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF Page link

Hi support,
I am trying to create a table with some page links. I used the code below. The table creates and appears in the pdf and the link seems to exist (i.e. when you cursor over it, a "hand" icon appears). However clicking the link does not do anything.

1. Did I miss anything in the code below?
2. There is one quirk in how I did this. At the time I create the link, the target page does not yet exist. , I am adding the pages after I create the link. Is that the problem and I need to create the link only after the pages exist?

Any guidance will be appreciated. Thanks,
Mike
p.s. Your support has been outstanding!


1. Create new document and page
-----------------------------------------------
dim pdf as new aspose.pdf.document()
Dim pdfPage As Aspose.Pdf.Page = pdf.Pages.Add()

2. add a table, row and cell to table
-----------------------------------
dim pdfTable as new aspose.pdf.table
Dim pdfRow As Aspose.Pdf.Row = pdfTable.Rows.Add()
Dim cell As Aspose.Pdf.Cell = Row.Cells.Add()

3. add link to cell
------------------------
Dim t As New Aspose.Pdf.Text.TextFragment("99")
Dim link As New Aspose.Pdf.LocalHyperlink()

link.TargetPageNumber = 99
t.Hyperlink = link

pdfRow.Cells(0).Paragraphs.Add(t)

(see my note above - this is where I add the additional pages)

4. Save it
---------------
pdfPage.Paragraphs.Add(pdfTable)
pdf.Save("myfile.pdf")

FYI - The problem was in my comment#2. The “target” page must exist at the time you set the link. It is all working now so you can disregard this question.


Best regards, Mike

Hi Mike,


Thanks for using our API’s.

Yes your findings are correct. Before setting target page link in PDF file, the page must be created in the document. You may also consider using doc.ProcessParagraphs(); method to render the pages inside the document and then call the code snippet to set link target.

Should you have any further query, please feel free to contact.