class PrintURLs
{
    /**
     * Constructor.
     */
    private PrintURLs()
    {
        //utility class
    }

    /**
     * This will output all URLs and the texts in the annotation rectangle of a document.
     * <br>
     * see usage() for commandline
     *
     * @param args Command line arguments.
     *
     * @throws IOException If there is an error extracting the URLs.
     */
    public static void main(String[] args) throws IOException
    {<FILL_FUNCTION_BODY>}

    private static PDActionURI getActionURI(PDAnnotation annot)
    {
        // use reflection to catch all annotation types that have getAction()
        // If you can't use reflection, then check for classes
        // PDAnnotationLink and PDAnnotationWidget, and call getAction() and check for a 
        // PDActionURI result type
        try
        {
            Method actionMethod = annot.getClass().getDeclaredMethod("getAction");
            if (actionMethod.getReturnType().equals(PDAction.class))
            {
                PDAction action = (PDAction) actionMethod.invoke(annot);
                if (action instanceof PDActionURI)
                {
                    return (PDActionURI) action;
                }
            }
        }
        catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e)
        {
        }
        return null;
    }

    /**
     * This will print out a message telling how to use this example.
     */
    private static void usage()
    {
        System.err.println( "usage: " + PrintURLs.class.getName() + " <input-file>" );
    }
}

        PDDocument doc = null;
        try
        {
            if( args.length != 1 )
            {
                usage();
            }
            else
            {
                doc = Loader.loadPDF(new File(args[0]));
                int pageNum = 0;
                for( PDPage page : doc.getPages() )
                {
                    pageNum++;
                    PDFTextStripperByArea stripper = new PDFTextStripperByArea();
                    List<PDAnnotation> annotations = page.getAnnotations();
                    //first setup text extraction regions
                    for( int j=0; j<annotations.size(); j++ )
                    {
                        PDAnnotation annot = annotations.get(j);

                        if (getActionURI(annot) != null)
                        {
                            PDRectangle rect = annot.getRectangle();
                            //need to reposition link rectangle to match text space
                            float x = rect.getLowerLeftX();
                            float y = rect.getUpperRightY();
                            float width = rect.getWidth();
                            float height = rect.getHeight();
                            int rotation = page.getRotation();
                            if( rotation == 0 )
                            {
                                PDRectangle pageSize = page.getMediaBox();
                                // area stripper uses java coordinates, not PDF coordinates
                                y = pageSize.getHeight() - y;
                            }
                            else
                            {
                                // do nothing
                                // please send us a sample file
                            }

                            Rectangle2D.Float awtRect = new Rectangle2D.Float( x,y,width,height );
                            stripper.addRegion( "" + j, awtRect );
                        }
                    }

                    stripper.extractRegions( page );

                    for( int j=0; j<annotations.size(); j++ )
                    {
                        PDAnnotation annot = annotations.get(j);
                        PDActionURI uri = getActionURI(annot);
                        if (uri != null)
                        {
                            String urlText = stripper.getTextForRegion("" + j);
                            System.out.println("Page " + pageNum + ":'" + urlText.trim() + "'=" + uri.getURI());
                        }
                    }
                }
            }
        }
        finally
        {
            if( doc != null )
            {
                doc.close();
            }
        }
    
<no_super_class>