How to get the page number of a Destination (in a GoToAction Annotation)

I’m examining a PDF that has been supplied to me. It contains internal hyperlinks (i.e. hyperlinks that take you to other pages within the document). For each hyperlink, I want to know the page number of the page it takes you to.


At the moment I’m looking at the Annotations property for each page: this gives me a list of hyperlinks on that page. I look at each one’s Action. Where it is a GoToAction, I examine the Destination.

What I’m finding is that the Destination is a NamedDestination, for example with the Name “appendix-a”.

What I want is the page number of the NamedDestination called “appendix-a”. How can I get this?

Thanks.

Hi Tim,

Thanks for your inquiry. In order to get the page number for named destination, PdfDocument.Destinations collection should be used. For example:

Document pdfDocument = new Document(myDir+"test.pdf");
int pageNumber1 = pdfDocument.Destinations.GetPageNumber("UntitledDestination", false);

Please feel free to contact us for any further assistance.

Best Regards,