Package org.pdfbox.pdmodel.interactive.documentnavigation.outline

Examples of org.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline


                List pages = document.getDocumentCatalog().getAllPages();
                if( pages.size() < 2 )
                {
                    throw new IOException( "Error: The PDF must have at least 2 pages.");
                }
                PDDocumentOutline bookmarks = document.getDocumentCatalog().getDocumentOutline();
                if( bookmarks == null )
                {
                    throw new IOException( "Error: The PDF does not contain any bookmarks" );
                }
                PDOutlineItem item = bookmarks.getFirstChild().getNextSibling();
                PDDestination dest = item.getDestination();
                PDActionGoTo action = new PDActionGoTo();
                action.setDestination(dest);        
                document.getDocumentCatalog().setOpenAction(action);
               
View Full Code Here


                //warning, potential for collision here!!
                destNames.getCOSDictionary().mergeInto( (COSDictionary)cloneForNewDocument( destination, srcNames ) );
            }
        }
       
        PDDocumentOutline destOutline = destCatalog.getDocumentOutline();
        PDDocumentOutline srcOutline = srcCatalog.getDocumentOutline();
        if( srcOutline != null )
        {
            if( destOutline == null )
            {
                PDDocumentOutline cloned =
                    new PDDocumentOutline( (COSDictionary)cloneForNewDocument( destination, srcOutline ) );
                destCatalog.setDocumentOutline( cloned );
            }
            else
            {
                PDOutlineItem first = srcOutline.getFirstChild();
View Full Code Here

                        System.err.println( "Error: Document is encrypted with a password." );
                        System.exit( 1 );
                    }
                }
                PrintBookmarks meta = new PrintBookmarks();
                PDDocumentOutline outline =  document.getDocumentCatalog().getDocumentOutline();
                if( outline != null )
                {
                    meta.printBookmark( outline, "" );
                }
                else
View Full Code Here

                if( document.isEncrypted() )
                {
                    System.err.println( "Error: Cannot add bookmarks to encrypted document." );
                    System.exit( 1 );
                }
                PDDocumentOutline outline =  new PDDocumentOutline();
                document.getDocumentCatalog().setDocumentOutline( outline );
                PDOutlineItem pagesOutline = new PDOutlineItem();
                pagesOutline.setTitle( "All Pages" );
                outline.appendChild( pagesOutline );
                List pages = document.getDocumentCatalog().getAllPages();
                for( int i=0; i<pages.size(); i++ )
                {
                    PDPage page = (PDPage)pages.get( i );
                    PDPageFitWidthDestination dest = new PDPageFitWidthDestination();
                    dest.setPage( page );
                    PDOutlineItem bookmark = new PDOutlineItem();
                    bookmark.setDestination( dest );
                    bookmark.setTitle( "Page " + (i+1) );
                    pagesOutline.appendChild( bookmark );
                }
                pagesOutline.openNode();
                outline.openNode();
               
                document.save( args[1] );
            }
            finally
            {
View Full Code Here

     *
     * @return The document's outline.
     */
    public PDDocumentOutline getDocumentOutline()
    {
        PDDocumentOutline retval = null;
        COSDictionary dict = (COSDictionary)root.getDictionaryObject( "Outlines" );
        if( dict != null )
        {
            retval = new PDDocumentOutline( dict );
        }
       
        return retval;
    }
View Full Code Here

      return bookmarks_;
    }

    private List extractBookmarks()
    {
        final PDDocumentOutline outline = getPDFDocument().getDocumentCatalog().getDocumentOutline();
        final List result = new ArrayList();
        if (outline != null)
        {
             PDOutlineItem child = outline.getFirstChild();
            while (child != null)
            {
              final PdfBoxPDFBookmark topBookmark = new PdfBoxPDFBookmark(child, null);
              result.add(topBookmark);
              result.addAll(topBookmark.getAllChildren());
View Full Code Here

    return bookMarkList;
  }

  private void getBookmarks() {
    bookMarkList = new ArrayList();
    PDDocumentOutline root = pdDocument.getDocumentCatalog()
        .getDocumentOutline();
    if (root != null) {
      PDOutlineItem item = root.getFirstChild();
      rekursionBookmarks(item);
    }
  }
View Full Code Here

TOP

Related Classes of org.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline

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.