How to extract hyper-references in a PDPage

Help
Peter M
2014-01-29
2014-01-29
  • Peter M
    Peter M
    2014-01-29

    Hi,

    I am trying to figure how to extract the hyper-references in a PDPage. For now I have the following code:

    List<PDAnnotation> lpda = page.getPDPage().getAnnotations();

    if (lpda != null) {

    Iterator<PDAnnotation> iterator = lpda.iterator();
    while (iterator.hasNext()) {
    
        PDAnnotation pda = iterator.next();
    
        if (pda.getAction() instanceof PDActionURI) {
    
            System.out.println("contents= " + pda.getContents());
            System.out.println("flags= " + pda.basicGetFlags());
            System.out.println("name= " + pda.getName());
            System.out.println("toString= " + pda.getAction().toString());
            System.out.println("rect= " + pda.getNormalizedRectangle().toString());
        }
    }
    

    }

    My questions are:

    1) Is pda.getNormalizedRectangle() the location of the URI in the PDF?

    2) How do I extract the hyperlink?

    Best,

    Peter

     
  • Peter M
    Peter M
    2014-01-29

    I was a little to fast. I am sorry. The answer in 2) is:

    PDActionURI pdauri = (PDActionURI) pda.getAction();
    pdauri.getURI()

    in 1) it is the location.

    Best, Peter

     
    Last edit: Peter M 2014-01-30