pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1636148 - in /pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel: PrintBookmarks.java PrintDocumentMetaData.java
Date Sun, 02 Nov 2014 16:38:11 GMT
Author: lehmi
Date: Sun Nov  2 16:38:11 2014
New Revision: 1636148

URL: http://svn.apache.org/r1636148
Log:
PDFBOX-2474: remove direct usage of PDFParser use PDDocument#load instead

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintDocumentMetaData.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java?rev=1636148&r1=1636147&r2=1636148&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintBookmarks.java
Sun Nov  2 16:38:11 2014
@@ -16,16 +16,14 @@
  */
 package org.apache.pdfbox.examples.pdmodel;
 
-import org.apache.pdfbox.pdfparser.PDFParser;
-
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
 import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline;
 import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
 import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode;
 
-import java.io.FileInputStream;
 import java.io.IOException;
+
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 
 /**
@@ -33,8 +31,8 @@ import org.apache.pdfbox.pdmodel.encrypt
  *
  * Usage: java org.apache.pdfbox.examples.pdmodel.PrintBookmarks <input-pdf>
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.2 $
+ * @author Ben Litchfield
+ * 
  */
 public class PrintBookmarks
 {
@@ -54,13 +52,9 @@ public class PrintBookmarks
         else
         {
             PDDocument document = null;
-            FileInputStream file = null;
             try
             {
-                file = new FileInputStream( args[0] );
-                PDFParser parser = new PDFParser( file );
-                parser.parse();
-                document = parser.getPDDocument();
+                document = PDDocument.load( args[0] );
                 if( document.isEncrypted() )
                 {
                     try
@@ -87,10 +81,6 @@ public class PrintBookmarks
             }
             finally
             {
-                if( file != null )
-                {
-                    file.close();
-                }
                 if( document != null )
                 {
                     document.close();

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintDocumentMetaData.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintDocumentMetaData.java?rev=1636148&r1=1636147&r2=1636148&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintDocumentMetaData.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/PrintDocumentMetaData.java
Sun Nov  2 16:38:11 2014
@@ -16,15 +16,12 @@
  */
 package org.apache.pdfbox.examples.pdmodel;
 
-import org.apache.pdfbox.pdfparser.PDFParser;
-
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.apache.pdfbox.pdmodel.PDDocumentInformation;
 import org.apache.pdfbox.pdmodel.common.PDMetadata;
 import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
 
-import java.io.FileInputStream;
 import java.io.IOException;
 
 import java.text.SimpleDateFormat;
@@ -37,8 +34,8 @@ import org.apache.pdfbox.pdmodel.encrypt
  *
  * Usage: java org.apache.pdfbox.examples.pdmodel.PrintDocumentMetaData &lt;input-pdf&gt;
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.11 $
+ * @author Ben Litchfield
+ * 
  */
 public class PrintDocumentMetaData
 {
@@ -58,13 +55,9 @@ public class PrintDocumentMetaData
         else
         {
             PDDocument document = null;
-            FileInputStream file = null;
             try
             {
-                file = new FileInputStream( args[0] );
-                PDFParser parser = new PDFParser( file );
-                parser.parse();
-                document = parser.getPDDocument();
+                document = PDDocument.load( args[0]);
                 if( document.isEncrypted() )
                 {
                     try
@@ -83,10 +76,6 @@ public class PrintDocumentMetaData
             }
             finally
             {
-                if( file != null )
-                {
-                    file.close();
-                }
                 if( document != null )
                 {
                     document.close();



Mime
View raw message