Package org.pdfclown.documents

Examples of org.pdfclown.documents.NamedDestinations


    {System.out.println("No names dictionary.");}
    else
    {
      System.out.println("Names dictionary found (" + names.getContainer().getReference() + ")");

      NamedDestinations namedDestinations = names.getDestinations();
      if(namedDestinations == null)
      {System.out.println("No named destinations.");}
      else
      {
        System.out.println("Named destinations found (" + namedDestinations.getContainer().getReference() + ")");

        // Parsing the named destinations...
        for(Map.Entry<PdfString,Destination> namedDestination : namedDestinations.entrySet())
        {
          PdfString key = namedDestination.getKey();
          Destination value = namedDestination.getValue();

          System.out.println("Destination '" + key.getValue() + "' (" + value.getContainer().getReference() + ")");

          System.out.print("    Target Page: number = ");
          Object pageRef = value.getPageRef();
          if(pageRef instanceof Integer) // NOTE: numeric page refs are typical of remote destinations.
          {System.out.println(((Integer)pageRef) + 1);}
          else // NOTE: explicit page refs are typical of local destinations.
          {
            Page page = (Page)pageRef;
            System.out.println((page.getIndex() + 1) + "; ID = " + ((PdfReference)page.getBaseObject()).getId());
          }
        }

        System.out.println("Named destinations count = " + namedDestinations.size());
      }
    }
   
    return true;
  }
View Full Code Here


    Document document = file.getDocument();
    Pages pages = document.getPages();

    // 2. Inserting page destinations...
    Names names = document.getNames(); if(names == null){document.setNames(names = new Names(document));}
    NamedDestinations destinations = names.getDestinations(); if(destinations == null){names.setDestinations(destinations = new NamedDestinations(document));}
    destinations.put(new PdfString("First page"), new LocalDestination(pages.get(0)));
    if(pages.size() > 1)
    {
      destinations.put(new PdfString("Second page"), new LocalDestination(pages.get(1), Destination.ModeEnum.FitHorizontal, new Float[]{0f}));

      if(pages.size() > 2)
      {destinations.put(new PdfString("Third page"), new LocalDestination(pages.get(2), Destination.ModeEnum.XYZ, new Float[]{50f,null,null}));}
    }

    // (boilerplate metadata insertion -- ignore it)
    buildAccessories(document,"Named destinations","manipulating named destinations");
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.NamedDestinations

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.