title: Hyperlink Detection from PDF
body: <p>I have some PDFs containing Hyperlinks both in form of URL and mailto. Now Is there any way or tool(may be 3rd party) to extract the Hyperlink meta information form the PDF like coordinates, link type and destination address. Any help is highly appreciated.</p>
  
  <p>I have already tried with iText and PDFBox but with no major success, even some third party software are not providing me the desired output.</p>
  
  <p>I have tried the following code in Java using iText</p>
  
  <pre><code>        PdfReader myReader = new PdfReader("pdf File Path");
          PdfDictionary pageDict = myReader.getPageN(1);
          PdfArray annots = pageDict.getAsArray(PdfName.ANNOTS);
          System.out.println(annots);
          ArrayList&lt;String&gt; dests = new ArrayList&lt;String&gt;();
          if(annots != null) 
          {
              for(int i=0; i&lt;annots.size(); ++i) 
              {
                  PdfDictionary annotDict = annots.getAsDict(i);
                  PdfName subType = annotDict.getAsName(PdfName.SUBTYPE);
                  if (subType != null &amp;&amp; PdfName.LINK.equals(subType)) 
                  {
                      PdfDictionary action = annotDict.getAsDict(PdfName.A);
                      if(action != null &amp;&amp; PdfName.URI.equals(action.getAsName(PdfName.S))) 
                      {
                          dests.add(action.getAsString(PdfName.URI).toString());
                      } // else { its an internal link }
                  }
              }
          }        
          System.out.println(dests);
  </code></pre>