I am trying PdfGoToAction in table of contents. I have below table of contents and the pdf document has 9 pages.
Content1..........................1
Content2..........................2
Content3..........................3
Content4..........................5
Content5..........................6
1. When I click 1 and 2, it jumps to the correct pages. But when I click 3, it jumps to page 4.
2. When I click 5, it jumps to the correct page - 5
2. There is no hyperlink when I hover over the text 6.
This is how I bring the table of contents
--------------------------------------------------
1. The pdf report is first generated with 7 pages.
2. I Insert the table of content (2 pages) after page 1 in the document.
This is the code I am using for goto page which is having issue.
-----------------------------------------------------------------------------
- Code: Select all
Dim tocPage As PdfNewPage = doc.Pages.Insert(i, page.Size) '' inserting a new page for table of content (2 pages in a loop)
tocPage.Canvas.DrawImage(image, 0, y + 17, 10.0F, 10.0F)
tocPage.Canvas.DrawString(Text, textFont, New PdfSolidBrush(New PdfRGBColor(67, 103, 155)), x + 20, y + 13)
tocPage.Canvas.DrawString(pageNumText, textFont, New PdfSolidBrush(New PdfRGBColor(67, 103, 155)), pageNumlocation, y + 13)
For j As Integer = dotLocation To pageNumlocation
If (dotLocation >= pageNumlocation) Then
Exit For
End If
tocPage.Canvas.DrawString(".", textFont, PdfBrushes.Black, dotLocation, y + 13)
dotLocation += 8
Next
Dim location = New PointF(0, y)
Dim titleBounds = New RectangleF(location, New SizeF(tocPage.Canvas.ClientSize.Width, titleSize.Height))
Dim Dest = New PdfDestination(doc.Pages(pp)) ''pp is the pagenumber
Dim Action = New PdfActionAnnotation(titleBounds, New PdfGoToAction(Dest))
Action.Border = New PdfAnnotationBorder(0)
tocPage.Annotations.Add(Action)
I tried doc.AfterOpenAction method which lands on the correct page. But the above code does not seem to work.
Please provide your expertise to solve this issue. Your help is much appreciated.
Thanks
Chitra