I am trying to get the links from the attached PDF file, but I am not
able to do it.
Below is the sample code that I am using
PDFDoc doc = new PDFDoc(input_path + "PM0609_004.pdf");
PageIterator end = doc.PageEnd();
for (PageIterator itr = doc.PageBegin(); itr!=end; itr.Next())
Page page = itr.Current();
int num_annots = page.GetNumAnnots(); // returns 0
for (int i=0; i<num_annots; ++i)
Using Acrobat viewer I am able to click on some of the hyperlinks.
We looked at the test files and there are no explicit link annotations
on any PDF page. Instead Acrobat viewer is trying to be 'smart' by
parsing/extracting the text content from the page and by recognizing
HTTP links. This could be also implemented using PDFNet, but would
involve additional coding (along the lines of TextExtract sample
but how can find out the box co-ordinates for the given text and apply links on top of it.
You could use element.GetBBox(rect) to get the box coordinates for
You would then create a new link annotation (i.e a hyperlink) as
illustrated in Annotation sample project and would add it to the page
using the above rectangle for positioning.