You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2014/11/03 15:05:25 UTC

svn commit: r1636356 [3/4] - in /pdfbox/branches/1.8/pdfbox/src: main/java/org/apache/pdfbox/cos/ main/java/org/apache/pdfbox/io/ main/java/org/apache/pdfbox/pdfparser/ main/java/org/apache/pdfbox/pdfviewer/ main/java/org/apache/pdfbox/pdmodel/ main/ja...

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Mon Nov  3 14:05:24 2014
@@ -440,6 +440,7 @@ public class COSDocument extends COSBase
     /**
      * This will return a list of signature fields.
      *
+     * @param onlyEmptyFields only empty signature fields will be returned
      * @return list of signature dictionaries as COSDictionary
      * @throws IOException if no document catalog can be found
      */
@@ -584,8 +585,8 @@ public class COSDocument extends COSBase
             }
             if (trailer != null)
             {
-            	trailer.clear();
-            	trailer = null;
+                trailer.clear();
+                trailer = null;
             }
             // Clear object pool
             List<COSObject> list = getObjects();
@@ -597,15 +598,15 @@ public class COSDocument extends COSBase
                     // clear the resources of the pooled objects
                     if (cosObject instanceof COSStream)
                     {
-                    	((COSStream)cosObject).close();
+                        ((COSStream)cosObject).close();
                     }
                     else if (cosObject instanceof COSDictionary)
                     {
-                    	((COSDictionary)cosObject).clear();
+                        ((COSDictionary)cosObject).clear();
                     }
                     else if (cosObject instanceof COSArray)
                     {
-                    	((COSArray)cosObject).clear();
+                        ((COSArray)cosObject).clear();
                     }
                     // TODO are there other kind of COSObjects to be cleared?
                 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java Mon Nov  3 14:05:24 2014
@@ -63,12 +63,18 @@ public class COSStream extends COSDictio
      */
     private RandomAccessFileOutputStream unFilteredStream;
 
-    private RandomAccess clone (RandomAccess file) {
-        if (file == null) {
+    private RandomAccess clone(RandomAccess file)
+    {
+        if (file == null)
+        {
             return null;
-        } else if (file instanceof RandomAccessFile) {
+        }
+        else if (file instanceof RandomAccessFile)
+        {
             return file;
-        } else {
+        }
+        else
+        {
             return ((RandomAccessBuffer)file).clone();
         }
     }
@@ -340,7 +346,7 @@ public class COSStream extends COSDictio
                 {
                     input = new BufferedInputStream(
                         new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
-                	IOUtils.closeQuietly(unFilteredStream);
+                    IOUtils.closeQuietly(unFilteredStream);
                     unFilteredStream = new RandomAccessFileOutputStream( file );
                     filter.decode( input, unFilteredStream, this, filterIndex );
                     done = true;
@@ -352,7 +358,7 @@ public class COSStream extends COSDictio
                 }
                 finally
                 {
-                	IOUtils.closeQuietly(input);
+                    IOUtils.closeQuietly(input);
                 }
             }
             if( !done )
@@ -368,7 +374,7 @@ public class COSStream extends COSDictio
                     {
                         input = new BufferedInputStream(
                             new RandomAccessFileInputStream( file, position, length ), BUFFER_SIZE );
-                    	IOUtils.closeQuietly(unFilteredStream);
+                        IOUtils.closeQuietly(unFilteredStream);
                         unFilteredStream = new RandomAccessFileOutputStream( file );
                         filter.decode( input, unFilteredStream, this, filterIndex );
                         done = true;
@@ -380,7 +386,7 @@ public class COSStream extends COSDictio
                     }
                     finally
                     {
-                    	IOUtils.closeQuietly(input);
+                        IOUtils.closeQuietly(input);
                     }
                 }
             }
@@ -468,9 +474,9 @@ public class COSStream extends COSDictio
      */
     public OutputStream createFilteredStream() throws IOException
     {
-    	IOUtils.closeQuietly(unFilteredStream);
-    	unFilteredStream = null;
-    	IOUtils.closeQuietly(filteredStream);
+        IOUtils.closeQuietly(unFilteredStream);
+        unFilteredStream = null;
+        IOUtils.closeQuietly(filteredStream);
         filteredStream = new RandomAccessFileOutputStream( file );
         return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
     }
@@ -488,9 +494,9 @@ public class COSStream extends COSDictio
      */
     public OutputStream createFilteredStream( COSBase expectedLength ) throws IOException
     {
-      	IOUtils.closeQuietly(unFilteredStream);
-       	unFilteredStream = null;
-    	IOUtils.closeQuietly(filteredStream);
+        IOUtils.closeQuietly(unFilteredStream);
+        unFilteredStream = null;
+        IOUtils.closeQuietly(filteredStream);
         filteredStream = new RandomAccessFileOutputStream( file );
         filteredStream.setExpectedLength( expectedLength );
         return new BufferedOutputStream( filteredStream, BUFFER_SIZE );
@@ -507,7 +513,7 @@ public class COSStream extends COSDictio
     {
         setItem(COSName.FILTER, filters);
         // kill cached filtered streams
-    	IOUtils.closeQuietly(filteredStream);
+        IOUtils.closeQuietly(filteredStream);
         filteredStream = null;
     }
 
@@ -522,33 +528,33 @@ public class COSStream extends COSDictio
     {
         IOUtils.closeQuietly(filteredStream);
         filteredStream = null;
-    	IOUtils.closeQuietly(unFilteredStream);
+        IOUtils.closeQuietly(unFilteredStream);
         unFilteredStream = new RandomAccessFileOutputStream( file );
         return new BufferedOutputStream( unFilteredStream, BUFFER_SIZE );
     }
     
     public void close()
     {
-    	try
-    	{
-    		if (file != null)
-    		{
-    			file.close();
-    			file = null;
-    		}
-    	}
-    	catch (IOException exception)
-    	{
-    		LOG.error("Exception occured when closing the file.", exception);
-    	}
-    	if (filteredStream != null)
-    	{
-    		IOUtils.closeQuietly(filteredStream);
-    	}
-    	if (unFilteredStream != null)
-    	{
-    		IOUtils.closeQuietly(unFilteredStream);
-    	}
-    	clear();
+        try
+        {
+            if (file != null)
+            {
+                file.close();
+                file = null;
+            }
+        }
+        catch (IOException exception)
+        {
+            LOG.error("Exception occured when closing the file.", exception);
+        }
+        if (filteredStream != null)
+        {
+            IOUtils.closeQuietly(filteredStream);
+        }
+        if (unFilteredStream != null)
+        {
+            IOUtils.closeQuietly(unFilteredStream);
+        }
+        clear();
     }
 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/PushBackInputStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/PushBackInputStream.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/PushBackInputStream.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/PushBackInputStream.java Mon Nov  3 14:05:24 2014
@@ -53,8 +53,7 @@ public class PushBackInputStream extends
             throw new IOException( "Error: input was null" );
         }
         
-        raInput = ( input instanceof RandomAccessRead ) ?
-										(RandomAccessRead) input : null;
+        raInput = (input instanceof RandomAccessRead) ? (RandomAccessRead) input : null;
     }
 
     /**
@@ -219,19 +218,20 @@ public class PushBackInputStream extends
      */
     public void seek( long newOffset ) throws IOException
     {
-    	if ( raInput == null )
-    			throw new IOException( "Provided stream of type " + in.getClass().getSimpleName() +
-    													 	 " is not seekable." );
-    	
-    	// clear unread buffer by skipping over all bytes of buffer
-    	int unreadLength = buf.length - pos;
-    	if ( unreadLength > 0 )
-    	{
-    			skip( unreadLength );
-    	}
-    	
-    	raInput.seek( newOffset );
-    	offset = newOffset;
+        if (raInput == null)
+        {
+            throw new IOException("Provided stream of type " + in.getClass().getSimpleName() + " is not seekable.");
+        }
+        
+        // clear unread buffer by skipping over all bytes of buffer
+        int unreadLength = buf.length - pos;
+        if (unreadLength > 0)
+        {
+            skip(unreadLength);
+        }
+
+        raInput.seek(newOffset);
+        offset = newOffset;
     }
 
 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java Mon Nov  3 14:05:24 2014
@@ -126,7 +126,7 @@ public class NonSequentialPDFParser exte
     private boolean isLenient = true;
 
     /**
-     * Contains all found objects of a brute force search
+     * Contains all found objects of a brute force search.
      */
     private HashMap<String, Long> bfSearchObjectOffsets = null;
     private HashMap<COSObjectKey, Long> bfSearchCOSObjectKeyOffsets = null;
@@ -343,24 +343,24 @@ public class NonSequentialPDFParser exte
      */
     protected void initialParse() throws IOException
     {
-    	COSDictionary trailer = null;
+        COSDictionary trailer = null;
         // ---- parse startxref
-    	long startXRefOffset = getStartxrefOffset();
-    	if (startXRefOffset > 0)
-    	{
-    		trailer = parseXref(startXRefOffset);
-    	}
-    	else if (isFDFDocment || isLenient)
-    	{
+        long startXRefOffset = getStartxrefOffset();
+        if (startXRefOffset > 0)
+        {
+            trailer = parseXref(startXRefOffset);
+        }
+        else if (isFDFDocment || isLenient)
+        {
             // signal start of new XRef
-            xrefTrailerResolver.nextXrefObj( startXRefOffset );
-    		bfSearchForObjects();
-    		for (COSObjectKey objectKey : bfSearchCOSObjectKeyOffsets.keySet())
-    		{
-	            xrefTrailerResolver.setXRef(objectKey, bfSearchCOSObjectKeyOffsets.get(objectKey));
-    		}
+            xrefTrailerResolver.nextXrefObj(startXRefOffset);
+            bfSearchForObjects();
+            for (COSObjectKey objectKey : bfSearchCOSObjectKeyOffsets.keySet())
+            {
+                xrefTrailerResolver.setXRef(objectKey, bfSearchCOSObjectKeyOffsets.get(objectKey));
+            }
             // parse the last trailer.
-    		pdfSource.seek(trailerOffset);
+            pdfSource.seek(trailerOffset);
             if (!parseTrailer())
             {
                 throw new IOException("Expected trailer object at position: "
@@ -369,9 +369,9 @@ public class NonSequentialPDFParser exte
             xrefTrailerResolver.setStartxref(startXRefOffset);
             trailer = xrefTrailerResolver.getCurrentTrailer();
             document.setTrailer(trailer);
-    	}
+        }
         // ---- prepare decryption if necessary
-    	prepareDecryption();
+        prepareDecryption();
 
         // PDFBOX-1557 - ensure that all COSObject are loaded in the trailer
         // PDFBOX-1606 - after securityHandler has been instantiated
@@ -396,7 +396,7 @@ public class NonSequentialPDFParser exte
         // ---- resolve all objects
         if (isFDFDocment)
         {
-        	// A FDF doesn't have a catalog, all FDF fields are within the root object
+            // A FDF doesn't have a catalog, all FDF fields are within the root object
             if (rootObject instanceof COSDictionary)
             {
                 parseDictObjects((COSDictionary) rootObject, (COSName[]) null);
@@ -494,8 +494,8 @@ public class NonSequentialPDFParser exte
         long fixedOffset = checkXRefOffset(startXrefOffset);
         if (fixedOffset > -1)
         {
-        	startXrefOffset = fixedOffset;
-        	document.setStartXref(startXrefOffset);
+            startXrefOffset = fixedOffset;
+            document.setStartXref(startXrefOffset);
         }
         long prev = startXrefOffset;
         // ---- parse whole chain of xref tables/object streams using PREV
@@ -538,7 +538,7 @@ public class NonSequentialPDFParser exte
                     fixedOffset = checkXRefOffset(streamOffset);
                     if (fixedOffset > -1 && fixedOffset != streamOffset)
                     {
-                    	streamOffset = (int)fixedOffset;
+                        streamOffset = (int)fixedOffset;
                         trailer.setInt(COSName.XREF_STM, streamOffset);
                     }
                     setPdfSource(streamOffset);
@@ -710,35 +710,35 @@ public class NonSequentialPDFParser exte
 
         if (bufOff < 0)
         {
-        	if (isLenient) 
-        	{
-        		// in lenient mode the '%%EOF' isn't needed
-        		bufOff = buf.length;
-        		LOG.debug("Missing end of file marker '" + (new String(EOF_MARKER)) + "'");
-        	} 
-        	else 
-        	{
-        		throw new IOException("Missing end of file marker '" + (new String(EOF_MARKER)) + "'");
-        	}
+            if (isLenient)
+            {
+                // in lenient mode the '%%EOF' isn't needed
+                bufOff = buf.length;
+                LOG.debug("Missing end of file marker '" + (new String(EOF_MARKER)) + "'");
+            }
+            else
+            {
+                throw new IOException("Missing end of file marker '" + (new String(EOF_MARKER)) + "'");
+            }
         }
         // ---- find last startxref preceding EOF marker
         bufOff = lastIndexOf(STARTXREF_MARKER, buf, bufOff);
 
         if (bufOff < 0)
         {
-        	if (isLenient) 
-        	{
+            if (isLenient)
+            {
                 trailerOffset = lastIndexOf(TRAILER_MARKER, buf, buf.length);
                 if (trailerOffset > 0)
                 {
-                	trailerOffset += skipBytes;
+                    trailerOffset += skipBytes;
                 }
-        		return -1;
-        	}
-        	else
-        	{
-        		throw new IOException("Missing 'startxref' marker.");
-        	}
+                return -1;
+            }
+            else
+            {
+                throw new IOException("Missing 'startxref' marker.");
+            }
         }
         return skipBytes + bufOff;
     }
@@ -866,17 +866,17 @@ public class NonSequentialPDFParser exte
             // a FDF doesn't have any pages
             if (!isFDFDocment)
             {
-	            final int pageCount = getPageNumber();
-	
-	            if (!allPagesParsed)
-	            {
-	                for (int pNr = 0; pNr < pageCount; pNr++)
-	                {
-	                    getPage(pNr);
-	                }
-	                allPagesParsed = true;
-	                document.setDecrypted();
-	            }
+                final int pageCount = getPageNumber();
+
+                if (!allPagesParsed)
+                {
+                    for (int pNr = 0; pNr < pageCount; pNr++)
+                    {
+                        getPage(pNr);
+                    }
+                    allPagesParsed = true;
+                    document.setDecrypted();
+                }
             }
             exceptionOccurred = false;
         }
@@ -934,8 +934,10 @@ public class NonSequentialPDFParser exte
      *
      * @throws IllegalArgumentException if the method is called after parsing.
      */
-    public void setLenient (boolean lenient) throws IllegalArgumentException {
-        if (initialParseDone) {
+    public void setLenient(boolean lenient) throws IllegalArgumentException
+    {
+        if (initialParseDone)
+        {
             throw new IllegalArgumentException("Cannot change leniency after parsing");
         }
         this.isLenient = lenient;
@@ -1669,24 +1671,24 @@ public class NonSequentialPDFParser exte
             // data, so just read those first
             while (whitespace == 0x20)
             {
-            	whitespace = pdfSource.read();
+                whitespace = pdfSource.read();
             }
 
             if (whitespace == 0x0D)
             {
-            	whitespace = pdfSource.read();
-            	if (whitespace != 0x0A)
-            	{
-            		// the spec says this is invalid but it happens in the
-            		// real world so we must support it
-            		pdfSource.unread(whitespace);
-            	}
+                whitespace = pdfSource.read();
+                if (whitespace != 0x0A)
+                {
+                    // the spec says this is invalid but it happens in the
+                    // real world so we must support it
+                    pdfSource.unread(whitespace);
+                }
             }
             else if (whitespace != 0x0A)
             {
-            	// no whitespace after 'stream'; PDF ref. says 'should' so
-            	// that is ok
-            	pdfSource.unread(whitespace);
+                // no whitespace after 'stream'; PDF ref. says 'should' so
+                // that is ok
+                pdfSource.unread(whitespace);
             }
 
             /*
@@ -1703,23 +1705,23 @@ public class NonSequentialPDFParser exte
             if (validateStreamLength(streamLengthObj.longValue()))
             {
                 out = stream.createFilteredStream(streamLengthObj);
-	            long remainBytes = streamLengthObj.longValue();
-	            int bytesRead = 0;
-	            while (remainBytes > 0)
-	            {
-	                final int readBytes = pdfSource.read(streamCopyBuf, 0,
-	                        (remainBytes > streamCopyBufLen) ? streamCopyBufLen : (int) remainBytes);
-	                if (readBytes <= 0)
-	                {
-	                    useReadUntilEnd = true;
-	                    out.close();
-	                    pdfSource.unread(bytesRead);
-	                    break;
-	                }
-	                out.write(streamCopyBuf, 0, readBytes);
-	                remainBytes -= readBytes;
-	                bytesRead += readBytes;
-	            }
+                long remainBytes = streamLengthObj.longValue();
+                int bytesRead = 0;
+                while (remainBytes > 0)
+                {
+                    final int readBytes = pdfSource.read(streamCopyBuf, 0,
+                            (remainBytes > streamCopyBufLen) ? streamCopyBufLen : (int) remainBytes);
+                    if (readBytes <= 0)
+                    {
+                        useReadUntilEnd = true;
+                        out.close();
+                        pdfSource.unread(bytesRead);
+                        break;
+                    }
+                    out.write(streamCopyBuf, 0, readBytes);
+                    remainBytes -= readBytes;
+                    bytesRead += readBytes;
+                }
             }
             else
             {
@@ -1764,30 +1766,30 @@ public class NonSequentialPDFParser exte
 
     private boolean validateStreamLength(long streamLength) throws IOException
     {
-    	boolean streamLengthIsValid = true;
-    	long originOffset = pdfSource.getOffset();
-    	long expectedEndOfStream = originOffset + streamLength;
-    	if (expectedEndOfStream > fileLen)
-    	{
-    		streamLengthIsValid = false;
-    		LOG.error("The end of the stream is out of range, using workaround to read the stream");
+        boolean streamLengthIsValid = true;
+        long originOffset = pdfSource.getOffset();
+        long expectedEndOfStream = originOffset + streamLength;
+        if (expectedEndOfStream > fileLen)
+        {
+            streamLengthIsValid = false;
+            LOG.error("The end of the stream is out of range, using workaround to read the stream");
+            LOG.error("Stream start offset: " + originOffset);
+            LOG.error("Expected endofstream offset: " + expectedEndOfStream);
+        }
+        else
+        {
+            pdfSource.seek(expectedEndOfStream);
+            skipSpaces();
+            if (!checkBytesAtOffset("endstream".getBytes("ISO-8859-1")))
+            {
+                streamLengthIsValid = false;
+                LOG.error("The end of the stream doesn't point to the correct offset, using workaround to read the stream");
                 LOG.error("Stream start offset: " + originOffset);
-                LOG.error("Expected endofstream offset: " + expectedEndOfStream);                          
-    	}
-    	else
-    	{
-			pdfSource.seek(expectedEndOfStream);
-			skipSpaces();
-	    	if (!checkBytesAtOffset("endstream".getBytes("ISO-8859-1")))
-	    	{
-	    		streamLengthIsValid = false;
-	    		LOG.error("The end of the stream doesn't point to the correct offset, using workaround to read the stream");
-                        LOG.error("Stream start offset: " + originOffset);
-                        LOG.error("Expected endofstream offset: " + expectedEndOfStream);                          
-	    	}
-    		pdfSource.seek(originOffset);
-    	}
-    	return streamLengthIsValid;
+                LOG.error("Expected endofstream offset: " + expectedEndOfStream);
+            }
+            pdfSource.seek(originOffset);
+        }
+        return streamLengthIsValid;
     }
     
     /**
@@ -1799,11 +1801,11 @@ public class NonSequentialPDFParser exte
      */
     private long checkXRefOffset(long startXRefOffset) throws IOException
     {
-    	// repair mode isn't available in non-lenient mode
-    	if (!isLenient)
-    	{
-    		return startXRefOffset;
-    	}
+        // repair mode isn't available in non-lenient mode
+        if (!isLenient)
+        {
+            return startXRefOffset;
+        }
         setPdfSource(startXRefOffset);
         if (pdfSource.peek() == X && checkBytesAtOffset(XREF_TABLE))
         {
@@ -1825,8 +1827,8 @@ public class NonSequentialPDFParser exte
             }
             catch (IOException exception)
             {
-            	// there wasn't an object of a xref stream
-            	// try to repair the offset
+                // there wasn't an object of a xref stream
+                // try to repair the offset
                 pdfSource.seek(startXRefOffset);
             }
         }
@@ -1843,28 +1845,28 @@ public class NonSequentialPDFParser exte
      */
     private boolean checkBytesAtOffset(byte[] string) throws IOException
     {
-    	boolean bytesMatching = false;
-		if (pdfSource.peek() == string[0])
-		{
-	    	int length = string.length;
-	    	byte[] bytesRead = new byte[length];
-			int numberOfBytes = pdfSource.read(bytesRead, 0, length);
-			while (numberOfBytes < length)
-			{
-				int readMore =  pdfSource.read(bytesRead, numberOfBytes, length-numberOfBytes);
-				if (readMore < 0)
-				{
-					break;
-				}
-				numberOfBytes += readMore;
-			}
-			if (Arrays.equals(string, bytesRead))
-			{
-				bytesMatching = true;
-			}
-			pdfSource.unread(bytesRead, 0, numberOfBytes);
-		}
-		return bytesMatching;
+        boolean bytesMatching = false;
+        if (pdfSource.peek() == string[0])
+        {
+            int length = string.length;
+            byte[] bytesRead = new byte[length];
+            int numberOfBytes = pdfSource.read(bytesRead, 0, length);
+            while (numberOfBytes < length)
+            {
+                int readMore = pdfSource.read(bytesRead, numberOfBytes, length - numberOfBytes);
+                if (readMore < 0)
+                {
+                    break;
+                }
+                numberOfBytes += readMore;
+            }
+            if (Arrays.equals(string, bytesRead))
+            {
+                bytesMatching = true;
+            }
+            pdfSource.unread(bytesRead, 0, numberOfBytes);
+        }
+        return bytesMatching;
     }
     
     /**
@@ -1901,11 +1903,11 @@ public class NonSequentialPDFParser exte
      */
     private void checkXrefOffsets() throws IOException
     {
-    	// repair mode isn't available in non-lenient mode
-    	if (!isLenient)
-    	{
-    		return;
-    	}
+        // repair mode isn't available in non-lenient mode
+        if (!isLenient)
+        {
+            return;
+        }
         Map<COSObjectKey, Long> xrefOffset = xrefTrailerResolver.getXrefTable();
         if (xrefOffset != null)
         {
@@ -2069,30 +2071,30 @@ public class NonSequentialPDFParser exte
      */
     private long bfSearchForXRef(long xrefOffset) throws IOException
     {
-    	long newOffset = -1;
-    	bfSearchForXRefs();
-    	if (bfSearchXRefOffsets != null)
-    	{
-	    	long currentDifference = -1;
-	    	int currentOffsetIndex = -1;
-	    	int numberOfOffsets = bfSearchXRefOffsets.size();
-	    	// find the most likely value
-	    	// TODO to be optimized, this won't work in every case
-	    	for (int i=0; i<numberOfOffsets; i++)
-	    	{
-	    		long newDifference = xrefOffset - bfSearchXRefOffsets.get(i);
-	    		// find the nearest offset
-	    		if (currentDifference == -1 || (Math.abs(currentDifference) > Math.abs(newDifference)))
-	    		{
-	    			currentDifference = newDifference;
-	        		currentOffsetIndex = i;
-	    		}
-	    	}
-	    	if (currentOffsetIndex > -1)
-	    	{
-	    		newOffset = bfSearchXRefOffsets.remove(currentOffsetIndex);
-	    	}
-    	}
+        long newOffset = -1;
+        bfSearchForXRefs();
+        if (bfSearchXRefOffsets != null)
+        {
+            long currentDifference = -1;
+            int currentOffsetIndex = -1;
+            int numberOfOffsets = bfSearchXRefOffsets.size();
+            // find the most likely value
+            // TODO to be optimized, this won't work in every case
+            for (int i = 0; i < numberOfOffsets; i++)
+            {
+                long newDifference = xrefOffset - bfSearchXRefOffsets.get(i);
+                // find the nearest offset
+                if (currentDifference == -1 || (Math.abs(currentDifference) > Math.abs(newDifference)))
+                {
+                    currentDifference = newDifference;
+                    currentOffsetIndex = i;
+                }
+            }
+            if (currentOffsetIndex > -1)
+            {
+                newOffset = bfSearchXRefOffsets.remove(currentOffsetIndex);
+            }
+        }
         return newOffset;
     }
 
@@ -2103,98 +2105,98 @@ public class NonSequentialPDFParser exte
      */
     private void bfSearchForXRefs() throws IOException
     {
-    	if (bfSearchXRefOffsets == null)
-    	{
+        if (bfSearchXRefOffsets == null)
+        {
             // a pdf may contain more than one xref entry
-    		bfSearchXRefOffsets = new Vector<Long>();
-    		long originOffset = pdfSource.getOffset();
-	        pdfSource.seek(MINIMUM_SEARCH_OFFSET);
-	        // search for xref tables
-	        while(!pdfSource.isEOF())
-	        {
-	            if (checkBytesAtOffset(XREF_TABLE))
-	            {
-	                long newOffset = pdfSource.getOffset(); 
-	                pdfSource.seek(newOffset-1);
-	                // ensure that we don't read "startxref" instead of "xref"
-	                if (isWhitespace())
-	                {
-	                    bfSearchXRefOffsets.add(newOffset);
-	                }
-	                pdfSource.seek(newOffset+4);
-	            }
-	            pdfSource.read();
-	        }
-	        pdfSource.seek(MINIMUM_SEARCH_OFFSET);
-	        // search for XRef streams
+            bfSearchXRefOffsets = new Vector<Long>();
+            long originOffset = pdfSource.getOffset();
+            pdfSource.seek(MINIMUM_SEARCH_OFFSET);
+            // search for xref tables
+            while (!pdfSource.isEOF())
+            {
+                if (checkBytesAtOffset(XREF_TABLE))
+                {
+                    long newOffset = pdfSource.getOffset();
+                    pdfSource.seek(newOffset - 1);
+                    // ensure that we don't read "startxref" instead of "xref"
+                    if (isWhitespace())
+                    {
+                        bfSearchXRefOffsets.add(newOffset);
+                    }
+                    pdfSource.seek(newOffset + 4);
+                }
+                pdfSource.read();
+            }
+            pdfSource.seek(MINIMUM_SEARCH_OFFSET);
+            // search for XRef streams
             String objString = " obj";
             byte[] string = objString.getBytes("ISO-8859-1");
-	        while(!pdfSource.isEOF())
-	        {
-	            if (checkBytesAtOffset(XREF_STREAM))
-	            {
-	            	// search backwards for the beginning of the stream
-	                long newOffset = -1;
-	            	long xrefOffset = pdfSource.getOffset();
-	            	long currentOffset = xrefOffset;
-	            	boolean objFound = false;
-	            	for (int i=1; i<30 && !objFound;i++)
-	            	{
-	            		currentOffset = xrefOffset - (i*10);
-	            		if (currentOffset > 0)
-	            		{
-	        	    		pdfSource.seek(currentOffset);
-	        	    		for (int j=0; j<10;j++)
-	        	    		{
-	        	    			if (checkBytesAtOffset(string))
-	        	    			{
-	        	                    long tempOffset = currentOffset - 1;
-	        	                    pdfSource.seek(tempOffset);
-	        	                    int genID = pdfSource.peek();
-	        	                    // is the next char a digit?
-	        	                    if (genID > 47 && genID < 58)
-	        	                    {
-	        	                        genID -= 48;
-	        	                        tempOffset--;
-	        	                        pdfSource.seek(tempOffset);
-	        	                        if (pdfSource.peek() == 32)
-	        	                        {
-	        	                            int length = 0;
-	        	                            pdfSource.seek(--tempOffset);
-	        	                            while (tempOffset > MINIMUM_SEARCH_OFFSET && pdfSource.peek() > 47
-	        	                                    && pdfSource.peek() < 58)
-	        	                            {
-	        	                                pdfSource.seek(--tempOffset);
-	        	                                length++;
-	        	                            }
-	        	                            if (length > 0)
-	        	                            {
-	        	                                pdfSource.read();
-	        	        		            	newOffset = pdfSource.getOffset();
-	        	                            }
-	        	                        }
-	        	                    }
-	        						LOG.debug("Fixed reference for xref stream "+xrefOffset + " -> "+newOffset);
-	        		            	objFound = true;
-	        		            	break;
-	        	    			}
-	        	    			else
-	        	    			{
-	        	    				currentOffset++;
-	        	    				pdfSource.read();
-	        	    			}
-	        	    		}
-	            		}
-	            	}
-	            	if (newOffset > -1)
-	            	{
-		                bfSearchXRefOffsets.add(newOffset);
-	            	}
-    				pdfSource.seek(xrefOffset+5);
-	            }
-	            pdfSource.read();
-	        }
-	        pdfSource.seek(originOffset);
-    	}
+            while (!pdfSource.isEOF())
+            {
+                if (checkBytesAtOffset(XREF_STREAM))
+                {
+                    // search backwards for the beginning of the stream
+                    long newOffset = -1;
+                    long xrefOffset = pdfSource.getOffset();
+                    long currentOffset = xrefOffset;
+                    boolean objFound = false;
+                    for (int i = 1; i < 30 && !objFound; i++)
+                    {
+                        currentOffset = xrefOffset - (i * 10);
+                        if (currentOffset > 0)
+                        {
+                            pdfSource.seek(currentOffset);
+                            for (int j = 0; j < 10; j++)
+                            {
+                                if (checkBytesAtOffset(string))
+                                {
+                                    long tempOffset = currentOffset - 1;
+                                    pdfSource.seek(tempOffset);
+                                    int genID = pdfSource.peek();
+                                    // is the next char a digit?
+                                    if (genID > 47 && genID < 58)
+                                    {
+                                        genID -= 48;
+                                        tempOffset--;
+                                        pdfSource.seek(tempOffset);
+                                        if (pdfSource.peek() == 32)
+                                        {
+                                            int length = 0;
+                                            pdfSource.seek(--tempOffset);
+                                            while (tempOffset > MINIMUM_SEARCH_OFFSET && pdfSource.peek() > 47
+                                                    && pdfSource.peek() < 58)
+                                            {
+                                                pdfSource.seek(--tempOffset);
+                                                length++;
+                                            }
+                                            if (length > 0)
+                                            {
+                                                pdfSource.read();
+                                                newOffset = pdfSource.getOffset();
+                                            }
+                                        }
+                                    }
+                                    LOG.debug("Fixed reference for xref stream " + xrefOffset + " -> " + newOffset);
+                                    objFound = true;
+                                    break;
+                                }
+                                else
+                                {
+                                    currentOffset++;
+                                    pdfSource.read();
+                                }
+                            }
+                        }
+                    }
+                    if (newOffset > -1)
+                    {
+                        bfSearchXRefOffsets.add(newOffset);
+                    }
+                    pdfSource.seek(xrefOffset + 5);
+                }
+                pdfSource.read();
+            }
+            pdfSource.seek(originOffset);
+        }
     }
 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java Mon Nov  3 14:05:24 2014
@@ -419,7 +419,7 @@ public class PDFParser extends BaseParse
         }
         else
         {
-        	isFDFDocment = true;
+            isFDFDocment = true;
             if (!header.matches(FDF_HEADER + "\\d.\\d"))
             {
                 if (header.length() < FDF_HEADER.length() + 3)
@@ -1078,17 +1078,18 @@ public class PDFParser extends BaseParse
      * {@inheritDoc}
      */
     @Override
-    public void clearResources() {
-    	super.clearResources();
-    	if (conflictList != null)
-    	{
-    		conflictList.clear();
-    		conflictList = null;
-    	}
-    	if (xrefTrailerResolver != null)
-    	{
-    		xrefTrailerResolver.clearResources();
-    		xrefTrailerResolver = null;
-    	}
+    public void clearResources()
+    {
+        super.clearResources();
+        if (conflictList != null)
+        {
+            conflictList.clear();
+            conflictList = null;
+        }
+        if (xrefTrailerResolver != null)
+        {
+            xrefTrailerResolver.clearResources();
+            xrefTrailerResolver = null;
+        }
     }
 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/XrefTrailerResolver.java Mon Nov  3 14:05:24 2014
@@ -76,15 +76,15 @@ public class XrefTrailerResolver
          */
         public void clearResources()
         {
-        	if (trailer != null)
-        	{
-        		trailer.clear();
-        		trailer = null;
-        	}
-        	if (xrefTable != null)
-        	{
-        		xrefTable.clear();
-        	}
+            if (trailer != null)
+            {
+                trailer.clear();
+                trailer = null;
+            }
+            if (xrefTable != null)
+            {
+                xrefTable.clear();
+            }
         }
     }
 
@@ -95,20 +95,24 @@ public class XrefTrailerResolver
     /** Log instance. */
     private static final Log LOG = LogFactory.getLog( XrefTrailerResolver.class );
 
-    public final COSDictionary getFirstTrailer() {
-    	if (bytePosToXrefMap.isEmpty()) return null;
-    	
-    	Set<Long> offsets = bytePosToXrefMap.keySet();
-    	SortedSet<Long> sortedOffset = new TreeSet<Long>(offsets);
-    	return bytePosToXrefMap.get(sortedOffset.first()).trailer;
+    public final COSDictionary getFirstTrailer()
+    {
+        if (bytePosToXrefMap.isEmpty())
+            return null;
+
+        Set<Long> offsets = bytePosToXrefMap.keySet();
+        SortedSet<Long> sortedOffset = new TreeSet<Long>(offsets);
+        return bytePosToXrefMap.get(sortedOffset.first()).trailer;
     }
     
-    public final COSDictionary getLastTrailer() {
-    	if (bytePosToXrefMap.isEmpty()) return null;
-    	
-    	Set<Long> offsets = bytePosToXrefMap.keySet();
-    	SortedSet<Long> sortedOffset = new TreeSet<Long>(offsets);
-    	return bytePosToXrefMap.get(sortedOffset.last()).trailer;
+    public final COSDictionary getLastTrailer()
+    {
+        if (bytePosToXrefMap.isEmpty())
+            return null;
+
+        Set<Long> offsets = bytePosToXrefMap.keySet();
+        SortedSet<Long> sortedOffset = new TreeSet<Long>(offsets);
+        return bytePosToXrefMap.get(sortedOffset.last()).trailer;
     }
     
     /**
@@ -305,20 +309,20 @@ public class XrefTrailerResolver
      */
     public void clearResources()
     {
-    	if (curXrefTrailerObj != null)
-    	{
-    		curXrefTrailerObj.clearResources();
-    		curXrefTrailerObj = null;
-    	}
-    	if (resolvedXrefTrailer != null)
-    	{
-    		resolvedXrefTrailer.clearResources();
-    		resolvedXrefTrailer = null;
-    	}
-    	if (bytePosToXrefMap != null)
-    	{
-    		bytePosToXrefMap.clear();
-    	}
+        if (curXrefTrailerObj != null)
+        {
+            curXrefTrailerObj.clearResources();
+            curXrefTrailerObj = null;
+        }
+        if (resolvedXrefTrailer != null)
+        {
+            resolvedXrefTrailer.clearResources();
+            resolvedXrefTrailer = null;
+        }
+        if (bytePosToXrefMap != null)
+        {
+            bytePosToXrefMap.clear();
+        }
     }
 
 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java Mon Nov  3 14:05:24 2014
@@ -401,7 +401,7 @@ public class PageDrawer extends PDFStrea
         BasicStroke currentStroke = null;
         if (stroke == null)
         {
-        	currentStroke = new BasicStroke(lineWidth);
+            currentStroke = new BasicStroke(lineWidth);
         }
         else
         {

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Mon Nov  3 14:05:24 2014
@@ -1537,24 +1537,24 @@ public class PDDocument implements Pagea
      */
     public void close() throws IOException
     {
-    	documentCatalog = null;
-    	documentInformation = null;
-    	encParameters = null;
-    	if (pageMap != null)
-    	{
-    		pageMap.clear();
-    		pageMap = null;
-    	}
-    	securityHandler = null;
-    	if (document != null)
-    	{
-	        document.close();
-	        document = null;
-    	}
+        documentCatalog = null;
+        documentInformation = null;
+        encParameters = null;
+        if (pageMap != null)
+        {
+            pageMap.clear();
+            pageMap = null;
+        }
+        securityHandler = null;
+        if (document != null)
+        {
+            document.close();
+            document = null;
+        }
         if (parser != null)
         {
-        	parser.clearResources();
-        	parser = null;
+            parser.clearResources();
+            parser = null;
         }
     }
 

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Mon Nov  3 14:05:24 2014
@@ -853,11 +853,11 @@ public class PDPage implements COSObject
             for (int i=0; i < annots.size(); i++)
             {
                 COSBase item = annots.getObject(i);
-            	if (item == null)
-            	{
-            		LOG.debug("Skipped annotation due to a null reference.");
-            		continue;
-            	}
+                if (item == null)
+                {
+                    LOG.debug("Skipped annotation due to a null reference.");
+                    continue;
+                }
                 actuals.add(PDAnnotation.createAnnotation(item));
             }
             retval = new COSArrayList<PDAnnotation>(actuals, annots);

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDMetadata.java Mon Nov  3 14:05:24 2014
@@ -100,7 +100,7 @@ public class PDMetadata extends PDStream
     public void importXMPMetadata( byte[] xmp )
         throws IOException
     {
-    	OutputStream os = createOutputStream();
+        OutputStream os = createOutputStream();
         os.write(xmp);
         os.close();
     }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/PublicKeySecurityHandler.java Mon Nov  3 14:05:24 2014
@@ -126,7 +126,7 @@ public class PublicKeySecurityHandler ex
         PDEncryptionDictionary dictionary = doc.getEncryptionDictionary();
 
         prepareForDecryption( dictionary, doc.getDocument().getDocumentID(),
-        											decryptionMaterial );
+                decryptionMaterial );
         
         proceedDecryption();
     }
@@ -145,116 +145,110 @@ public class PublicKeySecurityHandler ex
      * @throws CryptographyException If there is an error with decryption.
      */
     public void prepareForDecryption(PDEncryptionDictionary encDictionary, COSArray documentIDArray,
-				 														 DecryptionMaterial decryptionMaterial)
-    throws CryptographyException, IOException
+            DecryptionMaterial decryptionMaterial) throws CryptographyException, IOException
     {
-	      if(!(decryptionMaterial instanceof PublicKeyDecryptionMaterial))
-	      {
-	          throw new CryptographyException(
-	              "Provided decryption material is not compatible with the document");
-	      }
-
-	      decryptMetadata = encDictionary.isEncryptMetaData();
-          if(encDictionary.getLength() != 0)
-          {
-              this.keyLength = encDictionary.getLength();
-          }
-    
-	      
-	      PublicKeyDecryptionMaterial material = (PublicKeyDecryptionMaterial)decryptionMaterial;
-	
-	      try
-	      {
-	          boolean foundRecipient = false;
-	
-	          // the decrypted content of the enveloped data that match
-	          // the certificate in the decryption material provided
-	          byte[] envelopedData = null;
-	
-	          // the bytes of each recipient in the recipients array
-	          byte[][] recipientFieldsBytes = new byte[encDictionary.getRecipientsLength()][];
-	
-	          int recipientFieldsLength = 0;
-	
-	          for(int i=0; i<encDictionary.getRecipientsLength(); i++)
-	          {
-	              COSString recipientFieldString = encDictionary.getRecipientStringAt(i);
-	              byte[] recipientBytes = recipientFieldString.getBytes();
-	              CMSEnvelopedData data = new CMSEnvelopedData(recipientBytes);
-	              Iterator recipCertificatesIt = data.getRecipientInfos().getRecipients().iterator();
-	              while(recipCertificatesIt.hasNext())
-	              {
-	                  RecipientInformation ri =
-	                      (RecipientInformation)recipCertificatesIt.next();
-	                  // Impl: if a matching certificate was previously found it is an error,
-	                  // here we just don't care about it
-	                  if(ri.getRID().match(material.getCertificate()) && !foundRecipient)
-	                  {
-	                      foundRecipient = true;
-	                      envelopedData = ri.getContent(material.getPrivateKey(), "BC");
-	                      break;
-	                  }
-	              }
-	              recipientFieldsBytes[i] = recipientBytes;
-	              recipientFieldsLength += recipientBytes.length;
-	          }
-	          if(!foundRecipient || envelopedData == null)
-	          {
-	              throw new CryptographyException("The certificate matches no recipient entry");
-	          }
-	          if(envelopedData.length != 24)
-	          {
-	              throw new CryptographyException("The enveloped data does not contain 24 bytes");
-	          }
-	          // now envelopedData contains:
-	          // - the 20 bytes seed
-	          // - the 4 bytes of permission for the current user
-	
-	          byte[] accessBytes = new byte[4];
-	          System.arraycopy(envelopedData, 20, accessBytes, 0, 4);
-	
-	          currentAccessPermission = new AccessPermission(accessBytes);
-	          currentAccessPermission.setReadOnly();
-	
-	           // what we will put in the SHA1 = the seed + each byte contained in the recipients array
-	          byte[] sha1Input = new byte[recipientFieldsLength + 20];
-	
-	          // put the seed in the sha1 input
-	          System.arraycopy(envelopedData, 0, sha1Input, 0, 20);
-	
-	          // put each bytes of the recipients array in the sha1 input
-	          int sha1InputOffset = 20;
-	          for(int i=0; i<recipientFieldsBytes.length; i++)
-	          {
-	              System.arraycopy(
-	                  recipientFieldsBytes[i], 0,
-	                  sha1Input, sha1InputOffset, recipientFieldsBytes[i].length);
-	              sha1InputOffset += recipientFieldsBytes[i].length;
-	          }
-	
-	          MessageDigest md = MessageDigest.getInstance("SHA-1");
-	          byte[] mdResult = md.digest(sha1Input);
-	
-	          // we have the encryption key ...
-	          encryptionKey = new byte[this.keyLength/8];
-	          System.arraycopy(mdResult, 0, encryptionKey, 0, this.keyLength/8);
-	      }
-	      catch(CMSException e)
-	      {
-	          throw new CryptographyException(e);
-	      }
-	      catch(KeyStoreException e)
-	      {
-	          throw new CryptographyException(e);
-	      }
-	      catch(NoSuchProviderException e)
-	      {
-	          throw new CryptographyException(e);
-	      }
-	      catch(NoSuchAlgorithmException e)
-	      {
-	          throw new CryptographyException(e);
-	      }
+        if (!(decryptionMaterial instanceof PublicKeyDecryptionMaterial))
+        {
+            throw new CryptographyException("Provided decryption material is not compatible with the document");
+        }
+
+        decryptMetadata = encDictionary.isEncryptMetaData();
+        if (encDictionary.getLength() != 0)
+        {
+            this.keyLength = encDictionary.getLength();
+        }
+
+        PublicKeyDecryptionMaterial material = (PublicKeyDecryptionMaterial) decryptionMaterial;
+
+        try
+        {
+            boolean foundRecipient = false;
+
+            // the decrypted content of the enveloped data that match
+            // the certificate in the decryption material provided
+            byte[] envelopedData = null;
+
+            // the bytes of each recipient in the recipients array
+            byte[][] recipientFieldsBytes = new byte[encDictionary.getRecipientsLength()][];
+
+            int recipientFieldsLength = 0;
+
+            for (int i = 0; i < encDictionary.getRecipientsLength(); i++)
+            {
+                COSString recipientFieldString = encDictionary.getRecipientStringAt(i);
+                byte[] recipientBytes = recipientFieldString.getBytes();
+                CMSEnvelopedData data = new CMSEnvelopedData(recipientBytes);
+                Iterator recipCertificatesIt = data.getRecipientInfos().getRecipients().iterator();
+                while (recipCertificatesIt.hasNext())
+                {
+                    RecipientInformation ri = (RecipientInformation) recipCertificatesIt.next();
+                    // Impl: if a matching certificate was previously found it is an error,
+                    // here we just don't care about it
+                    if (ri.getRID().match(material.getCertificate()) && !foundRecipient)
+                    {
+                        foundRecipient = true;
+                        envelopedData = ri.getContent(material.getPrivateKey(), "BC");
+                        break;
+                    }
+                }
+                recipientFieldsBytes[i] = recipientBytes;
+                recipientFieldsLength += recipientBytes.length;
+            }
+            if (!foundRecipient || envelopedData == null)
+            {
+                throw new CryptographyException("The certificate matches no recipient entry");
+            }
+            if (envelopedData.length != 24)
+            {
+                throw new CryptographyException("The enveloped data does not contain 24 bytes");
+            }
+            // now envelopedData contains:
+            // - the 20 bytes seed
+            // - the 4 bytes of permission for the current user
+
+            byte[] accessBytes = new byte[4];
+            System.arraycopy(envelopedData, 20, accessBytes, 0, 4);
+
+            currentAccessPermission = new AccessPermission(accessBytes);
+            currentAccessPermission.setReadOnly();
+
+            // what we will put in the SHA1 = the seed + each byte contained in the recipients array
+            byte[] sha1Input = new byte[recipientFieldsLength + 20];
+
+            // put the seed in the sha1 input
+            System.arraycopy(envelopedData, 0, sha1Input, 0, 20);
+
+            // put each bytes of the recipients array in the sha1 input
+            int sha1InputOffset = 20;
+            for (int i = 0; i < recipientFieldsBytes.length; i++)
+            {
+                System.arraycopy(recipientFieldsBytes[i], 0, sha1Input, sha1InputOffset, recipientFieldsBytes[i].length);
+                sha1InputOffset += recipientFieldsBytes[i].length;
+            }
+
+            MessageDigest md = MessageDigest.getInstance("SHA-1");
+            byte[] mdResult = md.digest(sha1Input);
+
+            // we have the encryption key ...
+            encryptionKey = new byte[this.keyLength / 8];
+            System.arraycopy(mdResult, 0, encryptionKey, 0, this.keyLength / 8);
+        }
+        catch (CMSException e)
+        {
+            throw new CryptographyException(e);
+        }
+        catch (KeyStoreException e)
+        {
+            throw new CryptographyException(e);
+        }
+        catch (NoSuchProviderException e)
+        {
+            throw new CryptographyException(e);
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            throw new CryptographyException(e);
+        }
     }
     
     /**

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFAnnotation.java Mon Nov  3 14:05:24 2014
@@ -182,14 +182,14 @@ public abstract class FDFAnnotation impl
         FDFAnnotation retval = null;
         if( fdfDic != null )
         {
-	        if( FDFAnnotationText.SUBTYPE.equals( fdfDic.getNameAsString( COSName.SUBTYPE ) ) )
-	        {
-	            retval = new FDFAnnotationText( fdfDic );
-	        }
-	        else
-	        {
-	            LOG.warn("Unknown annotation type '" + fdfDic.getNameAsString( COSName.SUBTYPE ) + "'" );
-	        }
+            if (FDFAnnotationText.SUBTYPE.equals(fdfDic.getNameAsString(COSName.SUBTYPE)))
+            {
+                retval = new FDFAnnotationText(fdfDic);
+            }
+            else
+            {
+                LOG.warn("Unknown annotation type '" + fdfDic.getNameAsString(COSName.SUBTYPE) + "'");
+            }
         }
         return retval;
     }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java Mon Nov  3 14:05:24 2014
@@ -320,22 +320,23 @@ public abstract class PDCIDFont extends 
             cmap = cmapObjects.get( cidSystemInfo );
             if (cmap == null)
             {
-            	InputStream cmapStream = null;
+                InputStream cmapStream = null;
                 try
                 {
                     // look for a predefined CMap with the given name
                     cmapStream = ResourceLoader.loadResource(resourceRootCMAP + cidSystemInfo);
                     if (cmapStream != null)
                     {
-                    	cmap = parseCmap(resourceRootCMAP, cmapStream);
-                    	if (cmap == null)
-                    	{
-                    		log.error("Error: Could not parse predefined CMAP file for '" + cidSystemInfo + "'");
-                    	}
+                        cmap = parseCmap(resourceRootCMAP, cmapStream);
+                        if (cmap == null)
+                        {
+                            log.error("Error: Could not parse predefined CMAP file for '" + cidSystemInfo + "'");
+                        }
                     }
                     else
                     {
-                		log.debug("Debug: '" + cidSystemInfo + "' isn't a predefined CMap, most likely it's embedded in the pdf itself.");
+                        log.debug("Debug: '" + cidSystemInfo
+                                + "' isn't a predefined CMap, most likely it's embedded in the pdf itself.");
                     }
                 }
                 catch(IOException exception) 
@@ -344,7 +345,7 @@ public abstract class PDCIDFont extends 
                 }
                 finally
                 {
-                	IOUtils.closeQuietly(cmapStream);
+                    IOUtils.closeQuietly(cmapStream);
                 }
             }
         }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java Mon Nov  3 14:05:24 2014
@@ -412,22 +412,22 @@ public abstract class PDSimpleFont exten
 
         if (cmap == null && cmapName != null) 
         {
-        	InputStream cmapStream = null;
+            InputStream cmapStream = null;
             try 
             {
                 // look for a predefined CMap with the given name
                 cmapStream = ResourceLoader.loadResource(resourceRootCMAP + cmapName);
                 if (cmapStream != null)
                 {
-                	cmap = parseCmap(resourceRootCMAP, cmapStream);
-                	if (cmap == null && encodingName == null)
-                	{
-                		LOG.error("Error: Could not parse predefined CMAP file for '" + cmapName + "'");
-                	}
+                    cmap = parseCmap(resourceRootCMAP, cmapStream);
+                    if (cmap == null && encodingName == null)
+                    {
+                        LOG.error("Error: Could not parse predefined CMAP file for '" + cmapName + "'");
+                    }
                 }
                 else
                 {
-            		LOG.debug("Debug: '" + cmapName + "' isn't a predefined map, most likely it's embedded in the pdf itself.");
+                    LOG.debug("Debug: '" + cmapName + "' isn't a predefined map, most likely it's embedded in the pdf itself.");
                 }
             }
             catch(IOException exception) 
@@ -436,7 +436,7 @@ public abstract class PDSimpleFont exten
             }
             finally
             {
-            	IOUtils.closeQuietly(cmapStream);
+                IOUtils.closeQuietly(cmapStream);
             }
         }
     }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceGray.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceGray.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceGray.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceGray.java Mon Nov  3 14:05:24 2014
@@ -85,24 +85,24 @@ public class PDDeviceGray extends PDColo
      */
     public ColorModel createColorModel( int bpc ) throws IOException
     {
-    	ColorModel colorModel = null;
-    	if (bpc == 8)
-    	{
-    		ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
-            int[] nBits = {bpc};
-            colorModel = new ComponentColorModel(cs, nBits, false, false, Transparency.OPAQUE,DataBuffer.TYPE_BYTE);
-    	}
-    	else
-    	{
-        	int numEntries = 1 << bpc;
+        ColorModel colorModel = null;
+        if (bpc == 8)
+        {
+            ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+            int[] nBits = { bpc };
+            colorModel = new ComponentColorModel(cs, nBits, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
+        }
+        else
+        {
+            int numEntries = 1 << bpc;
             // calculate all possible values
             byte[] indexedValues = new byte[numEntries];
-            for (int i = 0; i < numEntries; i++) 
+            for (int i = 0; i < numEntries; i++)
             {
-            	indexedValues[i] = (byte)(i*255/(numEntries - 1));
+                indexedValues[i] = (byte) (i * 255 / (numEntries - 1));
             }
             colorModel = new IndexColorModel(bpc, numEntries, indexedValues, indexedValues, indexedValues);
-    	}
+        }
         return colorModel;
     }
 }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/CompositeImage.java Mon Nov  3 14:05:24 2014
@@ -121,15 +121,15 @@ public class CompositeImage
      */
     public BufferedImage createStencilMaskedImage(COSArray decodeArray)
     {
-    	// default: 0 (black) == opaque
+        // default: 0 (black) == opaque
         int alphaValue = 0;
         if (decodeArray != null)
         {
-        	// invert the stencil mask: 1 (white) == opaque
+            // invert the stencil mask: 1 (white) == opaque
             alphaValue = decodeArray.getInt(0) > decodeArray.getInt(1) ? 1 : 0;
         }
 
-    	final int baseImageWidth = baseImage.getWidth();
+        final int baseImageWidth = baseImage.getWidth();
         final int baseImageHeight = baseImage.getHeight();
         WritableRaster maskRaster = smaskImage.getRaster();
         BufferedImage result = new BufferedImage(baseImageWidth, baseImageHeight, BufferedImage.TYPE_INT_ARGB);

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java Mon Nov  3 14:05:24 2014
@@ -376,7 +376,7 @@ public class PDPixelMap extends PDXObjec
     
  
 
-	/**
+    /**
      * Writes the image as .png.
      *
      * {@inheritDoc}

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java Mon Nov  3 14:05:24 2014
@@ -159,14 +159,14 @@ public abstract class PDXObjectImage ext
             BufferedImage smaskBI = smask.getRGBImage();
             if (smaskBI != null)
             {
-	            COSArray decodeArray = smask.getDecode();
-	            CompositeImage compositeImage = new CompositeImage(baseImage, smaskBI);
-	            BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
-	            return rgbImage;
+                COSArray decodeArray = smask.getDecode();
+                CompositeImage compositeImage = new CompositeImage(baseImage, smaskBI);
+                BufferedImage rgbImage = compositeImage.createMaskedImage(decodeArray);
+                return rgbImage;
             }
             else
             {
-            	// this may happen if the smask is somehow broken, e.g. unsupported filter
+                // this may happen if the smask is somehow broken, e.g. unsupported filter
                 LOG.warn("masking getRGBImage returned NULL");
             }
         }
@@ -175,13 +175,14 @@ public abstract class PDXObjectImage ext
     
     public boolean hasMask() throws IOException
     {
-    	return getImageMask() || getMask() != null || getSMaskImage() != null;
+        return getImageMask() || getMask() != null || getSMaskImage() != null;
     }
     
     
     public BufferedImage imageMask(BufferedImage baseImage) throws IOException 
     {
-    	BufferedImage stencilMask = new BufferedImage(baseImage.getWidth(), baseImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
+        BufferedImage stencilMask = new BufferedImage(baseImage.getWidth(), baseImage.getHeight(),
+                BufferedImage.TYPE_INT_ARGB);
         Graphics2D graphics = (Graphics2D)stencilMask.getGraphics();
         if (getStencilColor() != null)
         {
@@ -211,26 +212,28 @@ public abstract class PDXObjectImage ext
     }
     
     public BufferedImage mask(BufferedImage baseImage) 
-    	throws IOException
+            throws IOException
     {
         COSBase mask = getMask();
         if (mask instanceof COSStream)
         {
-        	PDXObjectImage maskImageRef = (PDXObjectImage)PDXObject.createXObject((COSStream)mask);
-        	BufferedImage maskImage = maskImageRef.getRGBImage();
-       	 	if(maskImage == null)
-       	 	{
-    	   		 LOG.warn("masking getRGBImage returned NULL");
-    	   		 return baseImage;
-       	 	}
-       	 
-    	   	 BufferedImage newImage = new BufferedImage( maskImage.getWidth(), maskImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
-    	   	 Graphics2D graphics = (Graphics2D)newImage.getGraphics();
-    	   	 graphics.drawImage(baseImage, 0, 0, maskImage.getWidth(), maskImage.getHeight(), 0, 0, baseImage.getWidth(), baseImage.getHeight(), null);   
-    	   	 graphics.setComposite(AlphaComposite.DstIn);
-    	   	 graphics.drawImage(maskImage, null, 0, 0);
-    	   	 graphics.dispose();
-    	   	 return newImage;
+            PDXObjectImage maskImageRef = (PDXObjectImage) PDXObject.createXObject((COSStream) mask);
+            BufferedImage maskImage = maskImageRef.getRGBImage();
+            if (maskImage == null)
+            {
+                LOG.warn("masking getRGBImage returned NULL");
+                return baseImage;
+            }
+
+            BufferedImage newImage = new BufferedImage(maskImage.getWidth(), maskImage.getHeight(),
+                    BufferedImage.TYPE_INT_ARGB);
+            Graphics2D graphics = (Graphics2D) newImage.getGraphics();
+            graphics.drawImage(baseImage, 0, 0, maskImage.getWidth(), maskImage.getHeight(), 0, 0,
+                    baseImage.getWidth(), baseImage.getHeight(), null);
+            graphics.setComposite(AlphaComposite.DstIn);
+            graphics.drawImage(maskImage, null, 0, 0);
+            graphics.dispose();
+            return newImage;
         }
         else
         {

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java Mon Nov  3 14:05:24 2014
@@ -43,207 +43,226 @@ public interface PDFTemplateBuilder {
      * In order to create  Affine Transform, using parameters
      * @param params
      */
-	public void createAffineTransform(byte [] params);
-	
-	/**
-	 * Creates specified size page
-	 * @param properties
-	 */
-	public void createPage(PDVisibleSignDesigner properties);
-	
-	/**
-	 * Creates template using page
-	 * @param page
-	 * @throws IOException
-	 */
-	public void createTemplate(PDPage page) throws IOException;
-	
-	/**
-	 * Creates Acro forms in the template
-	 * @param template
-	 */
-	public void createAcroForm(PDDocument template);
-	
-	/**
-	 * Creates signature fields
-	 * @param acroForm
-	 * @throws IOException
-	 */
-	public void createSignatureField(PDAcroForm acroForm) throws IOException;
-	
-	/**
-	 * Creates PDSignature
-	 * @param pdSignatureField
-	 * @param page
-	 * @param signatureName
-	 * @throws IOException
-	 */
-	public void createSignature(PDSignatureField pdSignatureField, PDPage page, String signatureName) throws IOException;
-	
-	/**
-	 * Create AcroForm Dictionary
-	 * @param acroForm
-	 * @param signatureField
-	 * @throws IOException
-	 */
-	public void createAcroFormDictionary(PDAcroForm acroForm, PDSignatureField signatureField) throws IOException;
-	
-	/**
-	 * Creates SingatureRectangle
-	 * @param signatureField
-	 * @param properties
-	 * @throws IOException
-	 */
-	public void createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties) throws IOException;
-	
-	/**
-	 * Creates procSetArray of PDF,Text,ImageB,ImageC,ImageI    
-	 */
-	public void createProcSetArray();
-	
+    public void createAffineTransform(byte[] params);
+
+    /**
+     * Creates specified size page
+     * 
+     * @param properties
+     */
+    public void createPage(PDVisibleSignDesigner properties);
+
+    /**
+     * Creates template using page
+     * 
+     * @param page
+     * @throws IOException
+     */
+    public void createTemplate(PDPage page) throws IOException;
+
+    /**
+     * Creates Acro forms in the template
+     * 
+     * @param template
+     */
+    public void createAcroForm(PDDocument template);
+
+    /**
+     * Creates signature fields
+     * 
+     * @param acroForm
+     * @throws IOException
+     */
+    public void createSignatureField(PDAcroForm acroForm) throws IOException;
+
+    /**
+     * Creates PDSignature
+     * 
+     * @param pdSignatureField
+     * @param page
+     * @param signatureName
+     * @throws IOException
+     */
+    public void createSignature(PDSignatureField pdSignatureField, PDPage page, String signatureName)
+            throws IOException;
+
+    /**
+     * Create AcroForm Dictionary
+     * 
+     * @param acroForm
+     * @param signatureField
+     * @throws IOException
+     */
+    public void createAcroFormDictionary(PDAcroForm acroForm, PDSignatureField signatureField) throws IOException;
+
+    /**
+     * Creates SingatureRectangle
+     * 
+     * @param signatureField
+     * @param properties
+     * @throws IOException
+     */
+    public void createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties)
+            throws IOException;
+
+    /**
+     * Creates procSetArray of PDF,Text,ImageB,ImageC,ImageI
+     */
+    public void createProcSetArray();
+
     /**
      * Creates signature image
      * @param template
      * @param InputStream
      * @throws IOException
      */
-	public void createSignatureImage(PDDocument template, InputStream InputStream) throws IOException;
-	
-	/**
-	 * 
-	 * @param params
-	 */
-	public void createFormaterRectangle(byte [] params);
-	
-	/**
-	 * 
-	 * @param template
-	 */
-	public void createHolderFormStream(PDDocument template);
-	
-	/**
-	 * Creates resources of form
-	 */
-	public void createHolderFormResources();
-	
-	/**
-	 * Creates Form
-	 * @param holderFormResources
-	 * @param holderFormStream
-	 * @param formrect
-	 */
-	public void createHolderForm(PDResources holderFormResources, PDStream holderFormStream, PDRectangle formrect);
-	
-	/**
-	 * Creates appearance dictionary
-	 * @param holderForml
-	 * @param signatureField
-	 * @throws IOException
-	 */
-	public void createAppearanceDictionary(PDXObjectForm holderForml, PDSignatureField signatureField) throws IOException;
-	
-	/**
-	 * 
-	 * @param template
-	 */
-	public void createInnerFormStream(PDDocument template);
-	
-	
-	/**
-	 * Creates InnerForm
-	 */
-	public void createInnerFormResource();
-	
-	/**
-	 * 
-	 * @param innerFormResources
-	 * @param innerFormStream
-	 * @param formrect
-	 */
-	public void createInnerForm(PDResources innerFormResources, PDStream innerFormStream, PDRectangle formrect);
-	
-	
-	/**
-	 * 
-	 * @param innerForm
-	 * @param holderFormResources
-	 */
-	public void insertInnerFormToHolerResources(PDXObjectForm innerForm, PDResources holderFormResources);
-	
-	/**
-	 * 
-	 * @param template
-	 */
-	public void createImageFormStream(PDDocument template);
-	
-	/**
-	 * Create resource of image form
-	 */
-	public void createImageFormResources();
-	
-	/**
-	 * Creates Image form
-	 * @param imageFormResources
-	 * @param innerFormResource
-	 * @param imageFormStream
-	 * @param formrect
-	 * @param affineTransform
-	 * @param img
-	 * @throws IOException
-	 */
-	public void createImageForm(PDResources imageFormResources, PDResources innerFormResource, PDStream imageFormStream, PDRectangle formrect,
-			AffineTransform affineTransform, PDJpeg img) throws IOException;
-	
-	/**
-	 * Inject procSetArray 
-	 * @param innerForm
-	 * @param page
-	 * @param innerFormResources
-	 * @param imageFormResources
-	 * @param holderFormResources
-	 * @param procSet
-	 */
-	public void injectProcSetArray(PDXObjectForm innerForm, PDPage page, PDResources innerFormResources, PDResources imageFormResources,
-			PDResources holderFormResources, COSArray procSet);
-	
-	/**
-	 * injects appearance streams
-	 * @param holderFormStream
-	 * @param innterFormStream
-	 * @param imageFormStream
-	 * @param imageObjectName
-	 * @param imageName
-	 * @param innerFormName
-	 * @param properties
-	 * @throws IOException
-	 */
-	public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream, PDStream imageFormStream, String imageObjectName,
-			String imageName, String innerFormName, PDVisibleSignDesigner properties) throws IOException;
-	
-	/**
-	 * just to create visible signature
-	 * @param template
-	 */
-	public void createVisualSignature(PDDocument template);
-	
-	/**
-	 * adds Widget Dictionary
-	 * @param signatureField
-	 * @param holderFormResources
-	 * @throws IOException
-	 */
-	public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources) throws IOException;
-	
-	/**
-	 * 
-	 * @return - PDF template Structure
-	 */
-	public PDFTemplateStructure getStructure();
-	
-	/**
-	 * Closes template
-	 * @param template
-	 * @throws IOException
-	 */
-	public void closeTemplate(PDDocument template) throws IOException;
+    public void createSignatureImage(PDDocument template, InputStream InputStream) throws IOException;
+
+    /**
+     * 
+     * @param params
+     */
+    public void createFormaterRectangle(byte[] params);
+
+    /**
+     * 
+     * @param template
+     */
+    public void createHolderFormStream(PDDocument template);
+
+    /**
+     * Creates resources of form
+     */
+    public void createHolderFormResources();
+
+    /**
+     * Creates Form
+     * 
+     * @param holderFormResources
+     * @param holderFormStream
+     * @param formrect
+     */
+    public void createHolderForm(PDResources holderFormResources, PDStream holderFormStream, PDRectangle formrect);
+
+    /**
+     * Creates appearance dictionary
+     * 
+     * @param holderForml
+     * @param signatureField
+     * @throws IOException
+     */
+    public void createAppearanceDictionary(PDXObjectForm holderForml, PDSignatureField signatureField)
+            throws IOException;
+
+    /**
+     * 
+     * @param template
+     */
+    public void createInnerFormStream(PDDocument template);
+
+    /**
+     * Creates InnerForm
+     */
+    public void createInnerFormResource();
+
+    /**
+     * 
+     * @param innerFormResources
+     * @param innerFormStream
+     * @param formrect
+     */
+    public void createInnerForm(PDResources innerFormResources, PDStream innerFormStream, PDRectangle formrect);
+
+    /**
+     * 
+     * @param innerForm
+     * @param holderFormResources
+     */
+    public void insertInnerFormToHolerResources(PDXObjectForm innerForm, PDResources holderFormResources);
+
+    /**
+     * 
+     * @param template
+     */
+    public void createImageFormStream(PDDocument template);
+
+    /**
+     * Create resource of image form
+     */
+    public void createImageFormResources();
+
+    /**
+     * Creates Image form
+     * 
+     * @param imageFormResources
+     * @param innerFormResource
+     * @param imageFormStream
+     * @param formrect
+     * @param affineTransform
+     * @param img
+     * @throws IOException
+     */
+    public void createImageForm(PDResources imageFormResources, PDResources innerFormResource,
+            PDStream imageFormStream, PDRectangle formrect, AffineTransform affineTransform, PDJpeg img)
+            throws IOException;
+
+    /**
+     * Inject procSetArray
+     * 
+     * @param innerForm
+     * @param page
+     * @param innerFormResources
+     * @param imageFormResources
+     * @param holderFormResources
+     * @param procSet
+     */
+    public void injectProcSetArray(PDXObjectForm innerForm, PDPage page, PDResources innerFormResources,
+            PDResources imageFormResources, PDResources holderFormResources, COSArray procSet);
+
+    /**
+     * injects appearance streams
+     * 
+     * @param holderFormStream
+     * @param innterFormStream
+     * @param imageFormStream
+     * @param imageObjectName
+     * @param imageName
+     * @param innerFormName
+     * @param properties
+     * @throws IOException
+     */
+    public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream, PDStream imageFormStream,
+            String imageObjectName, String imageName, String innerFormName, PDVisibleSignDesigner properties)
+            throws IOException;
+
+    /**
+     * just to create visible signature
+     * 
+     * @param template
+     */
+    public void createVisualSignature(PDDocument template);
+
+    /**
+     * adds Widget Dictionary
+     * 
+     * @param signatureField
+     * @param holderFormResources
+     * @throws IOException
+     */
+    public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources)
+            throws IOException;
+
+    /**
+     * 
+     * @return - PDF template Structure
+     */
+    public PDFTemplateStructure getStructure();
+
+    /**
+     * Closes template
+     * 
+     * @param template
+     * @throws IOException
+     */
+    public void closeTemplate(PDDocument template) throws IOException;
 }

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=1636356&r1=1636355&r2=1636356&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 Mon Nov  3 14:05:24 2014
@@ -312,11 +312,11 @@ public class PDFTextStripper extends PDF
         document = null;
         if (charactersByArticle != null)
         {
-        	charactersByArticle.clear();
+            charactersByArticle.clear();
         }
         if (characterListMapping != null)
         {
-        	characterListMapping.clear();
+            characterListMapping.clear();
         }
         startBookmark = null;
         endBookmark = null;
@@ -591,11 +591,11 @@ public class PDFTextStripper extends PDF
                 // a custom quicksort implementation (which is slower, unfortunately).
                 if(useCustomQuicksort) 
                 {
-                	QuickSort.sort( textList, comparator );
+                    QuickSort.sort( textList, comparator );
                 } 
                 else 
                 {
-                	Collections.sort( textList, comparator );
+                    Collections.sort( textList, comparator );
                 }
             }
             Iterator<TextPosition> textIter = textList.iterator();
@@ -1856,7 +1856,7 @@ public class PDFTextStripper extends PDF
      */
     protected void setListItemPatterns(List<Pattern> patterns)
     {
-    	listOfPatterns = patterns;
+        listOfPatterns = patterns;
     }
 
     /**

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/GRestore.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/GRestore.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/GRestore.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/GRestore.java Mon Nov  3 14:05:24 2014
@@ -32,7 +32,7 @@ import org.apache.pdfbox.util.PDFOperato
  */
 public class GRestore extends OperatorProcessor
 {
-	
+
     /**
      * Log instance.
      */

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java?rev=1636356&r1=1636355&r2=1636356&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/operator/pagedrawer/StrokePath.java Mon Nov  3 14:05:24 2014
@@ -44,6 +44,6 @@ public class StrokePath extends Operator
      */
     public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
     {
-    	((PageDrawer)context).strokePath();
+        ((PageDrawer)context).strokePath();
     }
 }