pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1601932 - in /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox: ./ encryption/ pdmodel/graphics/color/ util/
Date Wed, 11 Jun 2014 15:40:32 GMT
Author: tilman
Date: Wed Jun 11 15:40:32 2014
New Revision: 1601932

URL: http://svn.apache.org/r1601932
Log:
PDFBOX-1474: removed catch handler for non existant InvalidPasswordException

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/ConvertColorspace.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFDebugger.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFReader.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFSplit.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFToImage.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/WriteDecodedDoc.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encryption/DocumentEncryption.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpaceFactory.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/ConvertColorspace.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/ConvertColorspace.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/ConvertColorspace.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/ConvertColorspace.java Wed
Jun 11 15:40:32 2014
@@ -25,7 +25,6 @@ import java.util.regex.Pattern;
 
 import org.apache.pdfbox.cos.COSFloat;
 import org.apache.pdfbox.cos.COSNumber;
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
 import org.apache.pdfbox.pdfwriter.ContentStreamWriter;
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -362,24 +361,7 @@ public class ConvertColorspace
             doc = PDDocument.load( inputFile );
             if( doc.isEncrypted() )
             {
-                try
-                {
-                    doc.decrypt( password );
-                }
-                catch( InvalidPasswordException e )
-                {
-                    if( !password.equals( "" ) )//they supplied the wrong password
-                    {
-                        System.err.println( "Error: The supplied password is incorrect."
);
-                        System.exit( 2 );
-                    }
-                    else
-                    {
-                        //they didn't suppply a password and the default of "" was wrong.
-                        System.err.println( "Error: The document is encrypted." );
-                        usage();
-                    }
-                }
+                doc.decrypt( password );
             }
             ConvertColorspace converter = new ConvertColorspace();
             converter.replaceColors(doc, colorEquivalents, destColorspace );

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFDebugger.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFDebugger.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFDebugger.java Wed Jun 11
15:40:32 2014
@@ -16,7 +16,6 @@
  */
 package org.apache.pdfbox;
 
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 
 import org.apache.pdfbox.pdfviewer.PDFTreeModel;
 import org.apache.pdfbox.pdfviewer.PDFTreeCellRenderer;
@@ -412,10 +411,6 @@ public class PDFDebugger extends javax.s
                 {
                     document.decrypt( password );
                 }
-                catch( InvalidPasswordException e )
-                {
-                    System.err.println( "Error: The document is encrypted." );
-                }
                 catch( org.apache.pdfbox.exceptions.CryptographyException e )
                 {
                     e.printStackTrace();

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFReader.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFReader.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFReader.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFReader.java Wed Jun 11 15:40:32
2014
@@ -16,7 +16,6 @@
  */
 package org.apache.pdfbox;
 
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.pdfviewer.PageWrapper;
 import org.apache.pdfbox.pdfviewer.ReaderBottomPanel;
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -399,10 +398,6 @@ public class PDFReader extends javax.swi
             {
                 document.decrypt( password );
             }
-            catch( InvalidPasswordException e )
-            {
-                System.err.println( "Error: The document is encrypted." );
-            }
             catch( org.apache.pdfbox.exceptions.CryptographyException e )
             {
                 e.printStackTrace();

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFSplit.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFSplit.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFSplit.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFSplit.java Wed Jun 11 15:40:32
2014
@@ -22,7 +22,6 @@ import java.io.FileOutputStream;
 
 import java.util.List;
 
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.exceptions.COSVisitorException;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -141,24 +140,7 @@ public class PDFSplit
                     document = PDDocument.load(pdfFile);
                     if( document.isEncrypted() )
                     {
-                        try
-                        {
-                            document.decrypt( password );
-                        }
-                        catch( InvalidPasswordException e )
-                        {
-                            if( args.length == 4 )//they supplied the wrong password
-                            {
-                                System.err.println( "Error: The supplied password is incorrect."
);
-                                System.exit( 2 );
-                            }
-                            else
-                            {
-                                //they didn't supply a password and the default of "" was
wrong.
-                                System.err.println( "Error: The document is encrypted." );
-                                usage();
-                            }
-                        }
+                        document.decrypt( password );
                     }
                 }
 

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFToImage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFToImage.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFToImage.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/PDFToImage.java Wed Jun 11
15:40:32 2014
@@ -24,7 +24,6 @@ import java.util.List;
 
 import javax.imageio.ImageIO;
 
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
@@ -182,24 +181,7 @@ public class PDFToImage
                     document = PDDocument.load( pdfFile );
                     if( document.isEncrypted() )
                     {
-                        try
-                        {
-                            document.decrypt( password );
-                        }
-                        catch( InvalidPasswordException e )
-                        {
-                            if( args.length == 4 )//they supplied the wrong password
-                            {
-                                System.err.println( "Error: The supplied password is incorrect."
);
-                                System.exit( 2 );
-                            }
-                            else
-                            {
-                                //they didn't supply a password and the default of "" was
wrong.
-                                System.err.println( "Error: The document is encrypted." );
-                                usage();
-                            }
-                        }
+                        document.decrypt( password );
                     }
                 }
                 int imageType = 24;

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/WriteDecodedDoc.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/WriteDecodedDoc.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/WriteDecodedDoc.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/WriteDecodedDoc.java Wed Jun
11 15:40:32 2014
@@ -28,7 +28,6 @@ import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.pdmodel.PDDocument;
 
 import org.apache.pdfbox.exceptions.COSVisitorException;
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 
 /**
  * load document and write with all streams decoded.
@@ -98,18 +97,6 @@ public class WriteDecodedDoc
                         doc.decrypt( password );
                         doc.setAllSecurityToBeRemoved(true);
                     }
-                    catch( InvalidPasswordException e )
-                    {
-                        if (password.trim().length() == 0)
-                        {
-                            System.err.println( "Password needed!!" );
-                        }
-                        else
-                        {
-                            System.err.println( "Wrong password!!" );
-                        }
-                        return;
-                    }
                     catch( org.apache.pdfbox.exceptions.CryptographyException e )
                     {
                         e.printStackTrace();

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encryption/DocumentEncryption.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encryption/DocumentEncryption.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encryption/DocumentEncryption.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encryption/DocumentEncryption.java
Wed Jun 11 15:40:32 2014
@@ -183,7 +183,6 @@ public class DocumentEncryption
 
         PDStandardEncryption encParameters = (PDStandardEncryption)pdDocument.getEncryptionDictionary();
 
-
         int permissions = encParameters.getPermissions();
         int revision = encParameters.getRevision();
         int length = encParameters.getLength()/8;

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpaceFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpaceFactory.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpaceFactory.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpaceFactory.java
Wed Jun 11 15:40:32 2014
@@ -21,6 +21,8 @@ import java.awt.color.ICC_ColorSpace;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
@@ -30,7 +32,6 @@ import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternResources;
 import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 
 /**
  * This class represents a color space in a pdf document.
@@ -41,6 +42,11 @@ import org.apache.pdfbox.pdmodel.graphic
 public final class PDColorSpaceFactory
 {
     /**
+     * Logger instance.
+     */
+    private static final Log LOG = LogFactory.getLog(PDColorSpaceFactory.class);
+    
+    /**
      * Private constructor for utility classes.
      */
     private PDColorSpaceFactory()
@@ -106,7 +112,12 @@ public final class PDColorSpaceFactory
             String name = ((COSName)array.getObject( 0 )).getName();
             if( name.equals( PDCalGray.NAME ) )
             {
-                retval = new PDCalGray( array );
+                // PDFBOX-1724
+                // https://github.com/mozilla/pdf.js/issues/252
+                LOG.warn("CalGray not implemented, using DeviceGray instead, see PDFBOX-1724");
+                retval = new PDDeviceGray();
+                //TH
+//                retval = new PDCalGray( array );
             }
             else if( name.equals( PDDeviceRGB.NAME ) )
             {

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java?rev=1601932&r1=1601931&r2=1601932&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java Wed
Jun 11 15:40:32 2014
@@ -37,7 +37,6 @@ import java.util.regex.Pattern;
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.exceptions.CryptographyException;
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.exceptions.WrappedIOException;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -341,10 +340,6 @@ public class PDFTextStripper extends PDF
             {
                 throw new WrappedIOException("Error decrypting document, details: ", e);
             }
-            catch (InvalidPasswordException e)
-            {
-                throw new WrappedIOException("Error: document is encrypted", e);
-            }
         }
         processPages( document.getDocumentCatalog().getAllPages() );
         endDocument(document);



Mime
View raw message