pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1801328 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
Date Sat, 08 Jul 2017 21:38:38 GMT
Author: tilman
Date: Sat Jul  8 21:38:38 2017
New Revision: 1801328

URL: http://svn.apache.org/viewvc?rev=1801328&view=rev
Log:
PDFBOX-3859: show destination page in GoTo actions too

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java?rev=1801328&r1=1801327&r2=1801328&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
(original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
Sat Jul  8 21:38:38 2017
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.IOException;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.interactive.action.PDActionGoTo;
 import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageDestination;
 import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline;
 import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
@@ -98,12 +99,20 @@ public class PrintBookmarks
             if (current.getDestination() instanceof PDPageDestination)
             {
                 PDPageDestination pd = (PDPageDestination) current.getDestination();
-                System.out.println("Destination page: " + pd.retrievePageNumber());
+                System.out.println("Destination page: " + (pd.retrievePageNumber() + 1));
+            }
+            if (current.getAction() instanceof PDActionGoTo)
+            {
+                PDActionGoTo gta = (PDActionGoTo) current.getAction();
+                if (gta.getDestination() instanceof PDPageDestination)
+                {
+                    PDPageDestination pd = (PDPageDestination) gta.getDestination();
+                    System.out.println("Destination page: " + (pd.retrievePageNumber() +
1));
+                }
             }
             System.out.println( indentation + current.getTitle() );
             printBookmark( document, current, indentation + "    " );
             current = current.getNextSibling();
         }
-
     }
 }



Mime
View raw message