Index: src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
===================================================================
--- src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java	(revision 766698)
+++ src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java	(working copy)
@@ -59,6 +59,8 @@
     public static final byte[] ENDSTREAM =
         new byte[] {101,110,100,115,116,114,101,97,109};//"endstream".getBytes( "ISO-8859-1" );
 
+    public static final byte[] ENDOBJ =
+        new byte[] {101,110,100,111,98,106};//"endobj".getBytes( "ISO-8859-1" );
     /**
      * This is a byte array that will be used for comparisons.
      */
@@ -293,20 +295,29 @@
 
             //Need to keep track of the
             out = stream.createFilteredStream( streamLength );
-            
+
             String endStream = null;
-            readUntilEndStream( out );
+            readUntilEndStream(out);
             skipSpaces();
             endStream = readString(); 
-            
+
             if (!endStream.equals("endstream")){
                 /*
+                 * Sometimes stream objects don't have an endstream tag so readUntilEndStream(out)
+                 * also can stop on endobj tags. If that's the case we need to make sure to unread
+                 * the endobj so parseObject() can handle that case normally. 
+                 */
+                if (endStream.startsWith("endobj")){
+                    byte[] endobjarray = endStream.getBytes();
+                    pdfSource.unread(endobjarray);
+                }
+                /*
                  * Some PDF files don't contain a new line after endstream so we 
                  * need to make sure that the next object number is getting read separately
                  * and not part of the endstream keyword. Ex. Some files would have "endstream8"
                  * instead of "endstream"
                  */
-                if(endStream.startsWith("endstream")){
+                else if(endStream.startsWith("endstream")){
                     String extra = endStream.substring(9, endStream.length());
                     endStream = endStream.substring(0, 9);
                     byte[] array = extra.getBytes();
@@ -334,48 +345,67 @@
         }
         return stream;
     }
-
+    /**
+     * This method will read through the current stream object until
+     * we find the keyword "endstream" meaning we're at the end of this
+     * object. Some pdf files, however, forget to write some endstream tags
+     * and just close off objects with an "endobj" tag so we have to handle
+     * this case as well.
+     * @param out The stream we write out to. 
+     * @throws IOException
+     */
     private void readUntilEndStream( OutputStream out ) throws IOException
     {
-        int currentIndex = 0;
         int byteRead = 0;
-        //this is the additional bytes buffered but not written
-        int additionalBytes=0;
-        byte[] buffer = new byte[ENDSTREAM.length+additionalBytes];
-        int writeIndex = 0;
-        while(!cmpCircularBuffer( buffer, currentIndex, ENDSTREAM ) && byteRead != -1 )
-        {
-            writeIndex = currentIndex - buffer.length;
-            if( writeIndex >= 0 )
-            {
-                out.write( buffer[writeIndex%buffer.length] );
+        byte[] buffer = new byte[ENDSTREAM.length];
+        int nextIdx = pdfSource.read(buffer) % buffer.length; 
+
+        while(byteRead != -1 ) {
+            if (cmpCircularBuffer( buffer, (nextIdx-ENDSTREAM.length + buffer.length)%buffer.length, ENDSTREAM )) {
+                pdfSource.unread( ENDSTREAM );
+                return;
             }
+            /*
+             * occasionally steam objects do not write the endstream tag and just terminate
+             * the object with an endobj tag so we want to stop there as well. 
+             */
+            int endObjStart = (nextIdx-ENDOBJ.length+ buffer.length)%buffer.length;
+            if (cmpCircularBuffer( buffer, endObjStart, ENDOBJ )) {
+                // data is written to out only when it is going to be overwritten.
+                // write out the rest of the data in the buffer since ENDOBJ is smaller then the buffer
+                for (int i = nextIdx; i < buffer.length && i < endObjStart; i++ ) {
+                    out.write(buffer[i]);
+                }
+                pdfSource.unread( ENDOBJ );
+                return;
+            }
+
+            out.write( buffer[nextIdx] );
+
             byteRead = pdfSource.read();
-            buffer[currentIndex%buffer.length] = (byte)byteRead;
-            currentIndex++;
-        }
-        pdfSource.unread( ENDSTREAM );
+            buffer[nextIdx] = (byte)byteRead;
 
+            if (++nextIdx == buffer.length) {
+                nextIdx = 0;
+            }
+        }   
     }
 
     /**
      * This basically checks to see if the next compareTo.length bytes of the
      * buffer match the compareTo byte array.
+     * @param buffer Circular buffer to look for string in
+     * @param currentIndex Index in buffer to start comparison from
+     * @param compareTo String to find in circular buffer at index
      */
     private boolean cmpCircularBuffer( byte[] buffer, int currentIndex, byte[] compareTo )
     {
         int cmpLen = compareTo.length;
         int buflen = buffer.length;
         boolean match = true;
-        int off = currentIndex-cmpLen;
-        if( off < 0 )
-        {
-            match = false;
+        for( int i=0; match && i<cmpLen; ++i ) {
+            match = buffer[(currentIndex+i)%buflen] == compareTo[i];
         }
-        for( int i=0; match && i<cmpLen; ++i )
-        {
-            match = buffer[(off+i)%buflen] == compareTo[i];
-        }
         return match;
     }