Package org.pdfbox.pdmodel.interactive.annotation

Examples of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink


                    for( int j=0; j<annotations.size(); j++ )
                    {
                        PDAnnotation annot = (PDAnnotation)annotations.get( j );
                        if( annot instanceof PDAnnotationLink )
                        {
                            PDAnnotationLink link = (PDAnnotationLink)annot;
                            PDRectangle rect = link.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.findRotation();
                            if( rotation == 0 )
                            {
                                PDRectangle pageSize = page.findMediaBox();
                                y = pageSize.getHeight() - y;
                            }
                            else if( rotation == 90 )
                            {
                                //do nothing
                            }
                           
                            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 = (PDAnnotation)annotations.get( j );
                        if( annot instanceof PDAnnotationLink )
                        {
                            PDAnnotationLink link = (PDAnnotationLink)annot;
                            PDAction action = link.getAction();
                            String urlText = stripper.getTextForRegion( "" + j );
                            if( action instanceof PDActionURI )
                            {
                                PDActionURI uri = (PDActionURI)action;
                                System.out.println( "Page " + (i+1) +":'" + urlText + "'=" + uri.getURI() );
View Full Code Here


                    for( int j=0; j<annotations.size(); j++ )
                    {
                        PDAnnotation annot = (PDAnnotation)annotations.get( j );
                        if( annot instanceof PDAnnotationLink )
                        {
                            PDAnnotationLink link = (PDAnnotationLink)annot;
                            PDAction action = link.getAction();
                            if( action instanceof PDActionURI )
                            {
                                PDActionURI uri = (PDActionURI)action;
                                String oldURI = uri.getURI();
                                String newURI = "http://www.pdfbox.org";
View Full Code Here

                txtMark.setContents("Highlighted since it's important");
               
                annotations.add(txtMark);
               
                // Now add the link annotation, so the clickme works
                PDAnnotationLink txtLink = new PDAnnotationLink();
                txtLink.setBorderStyle(borderULine);
               
                // Set the rectangle containing the link

                textWidth = (font.getStringWidth( "Click Here" )/1000) * 18;
                position = new PDRectangle();
                position.setLowerLeftX(inch)
                position.setLowerLeftY( ph-(float)(1.5*inch)-20)// down a couple of points
                position.setUpperRightX(72 + textWidth);
                position.setUpperRightY(ph-(float)(1.5*inch));
                txtLink.setRectangle(position);
               
                // add an action
                PDActionURI action = new PDActionURI();
                action.setURI("http://www.pdfbox.org");
                txtLink.setAction(action);
               
                annotations.add(txtLink);
               
               
                // Now draw a few more annotations
View Full Code Here

        }
    }

    private static void collateLinks(final List linkAnnotations, final List linkRegions, final Map uriMap, final Map textMap, final PDFTextStripperByArea stripper) throws IOException {
        for (int j = 0; j < linkAnnotations.size(); j++) {
            final PDAnnotationLink link = (PDAnnotationLink) linkAnnotations.get(j);
            final PDAction action = link.getAction();
            final String urlText = stripper.getTextForRegion(Integer.toString(j));
            if (action instanceof PDActionURI) {
              final PDActionURI uri = (PDActionURI) action;
                // internal links have no text
                if (urlText.length() > 0) {
View Full Code Here

TOP

Related Classes of org.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.