You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by je...@apache.org on 2014/05/29 17:04:16 UTC

svn commit: r1598316 - in /pdfbox/trunk: pdfbox/ pdfbox/src/main/java/org/apache/pdfbox/cos/ pdfbox/src/main/java/org/apache/pdfbox/encoding/ pdfbox/src/main/java/org/apache/pdfbox/pdfparser/ pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/ pdfbox/src...

Author: jeremias
Date: Thu May 29 15:04:15 2014
New Revision: 1598316

URL: http://svn.apache.org/r1598316
Log:
PDFBOX-2102: Fix for swallowed character in COSString.getString().
Introduced a java.nio.charset.Charset subclass implementing "PDFDocEncoding" fully, not just partially like in PdfDocEncoding. This should also be faster than the other class. It also made it possible to remove the requirement for the "isDictionaryValue" parameter introduced with PDFBOX-1437. Methods and constructors with that parameter are now marked deprecated and they have no internal references anymore. Compatibility of the change has been checked against the test file in PDFBOX-1437 and a unit test covers it, too.
There is a META-INF/services registration for the CharsetProvider but it is not used by PDFBox's code right now because it might be unreliable when PDFBox is used in environments like a WAR due to class loading issues. Still, it does no harm and maybe someone may find it useful.

Added:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/PDFBoxCharsetProvider.java
      - copied unchanged from r1598289, pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encoding/PDFBoxCharsetProvider.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/PDFDocEncodingCharset.java
      - copied unchanged from r1598289, pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encoding/PDFDocEncodingCharset.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/SingleByteCharset.java
      - copied unchanged from r1598289, pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/encoding/SingleByteCharset.java
    pdfbox/trunk/pdfbox/src/main/resources/META-INF/
      - copied from r1598289, pdfbox/branches/1.8/pdfbox/src/main/resources/META-INF/
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encoding/
      - copied from r1598289, pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/encoding/
Modified:
    pdfbox/trunk/pdfbox/pom.xml
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java

Modified: pdfbox/trunk/pdfbox/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/pom.xml?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/pom.xml (original)
+++ pdfbox/trunk/pdfbox/pom.xml Thu May 29 15:04:15 2014
@@ -83,7 +83,7 @@
             <groupId>net.java.dev.jai-imageio</groupId>
             <artifactId>jai-imageio-core-standalone</artifactId>
             <scope>test</scope>
-        </dependency>        
+        </dependency>
     </dependencies>
 
     <build>
@@ -148,6 +148,7 @@
                         <exclude>src/main/resources/org/apache/pdfbox/resources/afm/*</exclude>
                         <exclude>src/main/resources/org/apache/pdfbox/resources/cmap/*</exclude>
                         <exclude>src/main/resources/org/apache/pdfbox/resources/icc/*</exclude>
+                        <exclude>src/main/resources/META-INF/services/*</exclude>
                         <exclude>src/test/resources/input/rendering/*.ai</exclude>
                         <exclude>src/test/resources/output/*</exclude>
                         <exclude>release.properties</exclude>

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSString.java Thu May 29 15:04:15 2014
@@ -19,10 +19,11 @@ package org.apache.pdfbox.cos;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
-import org.apache.pdfbox.encoding.PdfDocEncoding;
+import org.apache.pdfbox.encoding.PDFDocEncodingCharset;
 import org.apache.pdfbox.persistence.util.COSHEXTable;
 
 /**
@@ -89,8 +90,6 @@ public class COSString extends COSBase
      */
     private boolean forceHexForm = false;
 
-    private boolean isDictionary = false;
-
     /**
      * Constructor.
      */
@@ -103,11 +102,12 @@ public class COSString extends COSBase
      * Constructor.
      * 
      * @param isDictionaryValue determines if this string represents a dictionary
+     * @deprecated Not needed anymore. Use {@link #COSString()} instead. PDFBOX-2102
      */
+    @Deprecated
     public COSString(boolean isDictionaryValue)
     {
         this();
-        isDictionary = isDictionaryValue;
     }
 
     /**
@@ -287,51 +287,25 @@ public class COSString extends COSBase
             return this.str;
         }
         String retval;
-        String encoding = "ISO-8859-1";
+        Charset charset = PDFDocEncodingCharset.INSTANCE;
         byte[] data = getBytes();
         int start = 0;
         if (data.length > 2)
         {
             if (data[0] == (byte) 0xFF && data[1] == (byte) 0xFE)
             {
-                encoding = "UTF-16LE";
+                charset = Charset.forName("UTF-16LE");
                 start = 2;
             }
             else if (data[0] == (byte) 0xFE && data[1] == (byte) 0xFF)
             {
-                encoding = "UTF-16BE";
+                charset = Charset.forName("UTF-16BE");
                 start = 2;
             }
         }
-        try
-        {
-            if (isDictionary && encoding.equals("ISO-8859-1"))
-            {
-                byte[] tmp = getBytes();
-                PdfDocEncoding pde = new PdfDocEncoding();
-                StringBuilder sb = new StringBuilder(tmp.length);
-                for (byte b : tmp)
-                {
-                    final String character = pde.getCharacter((b + 256) % 256);
-                    if (character != null)
-                    {
-                        sb.append(character);
-                    }
-                }
-                retval = sb.toString();
-            }
-            else
-            {
-                retval = new String(getBytes(), start, data.length - start, encoding);
-            }
-        }
-        catch (IOException e)
-        {
-            // should never happen
-            LOG.error(e,e);
-            retval = new String(getBytes());
-        }
-        this.str = retval;
+
+        retval = new String(data, start, data.length - start, charset);
+        str = retval;
         return retval;
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java Thu May 29 15:04:15 2014
@@ -281,7 +281,7 @@ public abstract class Encoding implement
         String name = getName(code);
         if (name != null)
         {
-            return getCharacter(getName(code));
+            return getCharacter(name);
         }
         return null;
     }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Thu May 29 15:04:15 2014
@@ -47,7 +47,7 @@ import org.apache.pdfbox.persistence.uti
  * PDFParser and the COSStreamParser.
  *
  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * 
+ * @version $Revision$
  */
 public abstract class BaseParser
 {
@@ -550,11 +550,8 @@ public abstract class BaseParser
                         out.flush();
                         InputStream writtenStreamBytes = stream.getFilteredStream();
                         ByteArrayOutputStream bout = new ByteArrayOutputStream( length );
-                        
-                        while ( ( readCount = writtenStreamBytes.read( strmBuf ) ) >= 0 )
-                        {
-                            bout.write( strmBuf, 0, readCount );
-                        }
+
+                        IOUtils.copy(writtenStreamBytes, bout);
                         IOUtils.closeQuietly(writtenStreamBytes);
                         try
                         {
@@ -568,7 +565,7 @@ public abstract class BaseParser
                                                    PROP_PUSHBACK_SIZE, ioe );
                         }
                         // close and create new filtered stream
-                      	IOUtils.closeQuietly(out);
+                        IOUtils.closeQuietly(out);
                         out = stream.createFilteredStream( streamLength );
                         // scan until we find endstream:
                         readUntilEndStream( new EndstreamOutputStream(out) );
@@ -799,6 +796,7 @@ public abstract class BaseParser
         }
         return braces;
     }
+
     /**
      * This will parse a PDF string.
      *
@@ -806,11 +804,25 @@ public abstract class BaseParser
      * @return The parsed PDF string.
      *
      * @throws IOException If there is an error reading from the stream.
+     * @deprecated Not needed anymore. Use {@link #parseCOSString()} instead. PDFBOX-1437
      */
+    @Deprecated
     protected COSString parseCOSString(boolean isDictionary) throws IOException
     {
+        return parseCOSString();
+    }
+
+    /**
+     * This will parse a PDF string.
+     *
+     * @return The parsed PDF string.
+     *
+     * @throws IOException If there is an error reading from the stream.
+     */
+    protected COSString parseCOSString() throws IOException
+    {
         char nextChar = (char)pdfSource.read();
-        COSString retval = new COSString(isDictionary);
+        COSString retval = new COSString();
         char openBrace;
         char closeBrace;
         if( nextChar == '(' )
@@ -1088,7 +1100,7 @@ public abstract class BaseParser
             else
             {
                 //it could be a bad object in the array which is just skipped
-                LOG.warn("Corrupt object reference" );
+                LOG.warn("Corrupt object reference at offset " + pdfSource.getOffset());
 
                 // This could also be an "endobj" or "endstream" which means we can assume that
                 // the array has ended.
@@ -1260,7 +1272,7 @@ public abstract class BaseParser
             }
             else
             {
-                retval = parseCOSString(true);
+                retval = parseCOSString();
             }
             break;
         }
@@ -1270,7 +1282,7 @@ public abstract class BaseParser
             break;
         }
         case '(':
-            retval = parseCOSString(true);
+            retval = parseCOSString();
             break;
         case '/':   // name
             retval = parseCOSName();
@@ -1610,27 +1622,29 @@ public abstract class BaseParser
      * This will read a long from the Stream and throw an {@link IllegalArgumentException} if the long value
      * has more than 10 digits (i.e. : bigger than {@link #OBJECT_NUMBER_THRESHOLD})
      * @return the object number being read.
-     * @throws IOException
+     * @throws IOException if an I/O error occurs
      */
     protected long readObjectNumber() throws IOException
     {
         long retval = readLong();
-        if(retval < 0 || retval >= OBJECT_NUMBER_THRESHOLD) {
+        if(retval < 0 || retval >= OBJECT_NUMBER_THRESHOLD)
+        {
             throw new IOException("Object Number '" + retval + "' has more than 10 digits or is negative");
         }
         return retval;
     }
-    
+
     /**
      * This will read a integer from the Stream and throw an {@link IllegalArgumentException} if the integer value
      * has more than the maximum object revision (i.e. : bigger than {@link #GENERATION_NUMBER_THRESHOLD})
      * @return the generation number being read.
-     * @throws IOException
+     * @throws IOException if an I/O error occurs
      */
     protected int readGenerationNumber() throws IOException
     {
         int retval = readInt();
-        if(retval < 0 || retval > GENERATION_NUMBER_THRESHOLD) {
+        if(retval < 0 || retval > GENERATION_NUMBER_THRESHOLD)
+        {
             throw new IOException("Generation Number '" + retval + "' has more than 5 digits");
         }
         return retval;
@@ -1684,14 +1698,16 @@ public abstract class BaseParser
         catch( NumberFormatException e )
         {
             pdfSource.unread(longBuffer.toString().getBytes("ISO-8859-1"));
-            throw new IOException( "Error: Expected a long type at offset "+pdfSource.getOffset() + ", instead got '" + longBuffer + "'");
+            throw new IOException( "Error: Expected a long type at offset "
+                    + pdfSource.getOffset() + ", instead got '" + longBuffer + "'");
         }
         return retval;
     }
 
     /**
-     * This method is used to read a token by the {@linkplain #readInt()} method and the {@linkplain #readLong()} method.
-     *  
+     * This method is used to read a token by the {@linkplain #readInt()} method
+     * and the {@linkplain #readLong()} method.
+     *
      * @return the token to parse as integer or long by the calling method.
      * @throws IOException throws by the {@link #pdfSource} methods.
      */
@@ -1721,11 +1737,11 @@ public abstract class BaseParser
      */
     public void clearResources()
     {
-    	document = null;
-    	if (pdfSource != null)
-    	{
-    		IOUtils.closeQuietly(pdfSource);
-    		pdfSource = null;
-    	}
+        document = null;
+        if (pdfSource != null)
+        {
+            IOUtils.closeQuietly(pdfSource);
+            pdfSource = null;
+        }
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java Thu May 29 15:04:15 2014
@@ -41,12 +41,12 @@ import org.apache.pdfbox.util.operator.P
  * This will parse a PDF byte stream and extract operands and such.
  *
  * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * 
+ * @version $Revision$
  */
 public class PDFStreamParser extends BaseParser
 {
     private List<Object> streamObjects = new ArrayList<Object>( 100 );
-    private RandomAccess file;
+    private final RandomAccess file;
     private final int    maxBinCharTestLength = 5;
     private final byte[] binCharTestArr = new byte[maxBinCharTestLength];
 
@@ -260,7 +260,7 @@ public class PDFStreamParser extends Bas
                 }
                 else
                 {
-                    retval = parseCOSString(false);
+                    retval = parseCOSString();
                 }
                 break;
             }
@@ -270,7 +270,7 @@ public class PDFStreamParser extends Bas
                 break;
             }
             case '(': // string
-                retval = parseCOSString(false);
+                retval = parseCOSString();
                 break;
             case '/':   // name
                 retval = parseCOSName();
@@ -360,7 +360,7 @@ public class PDFStreamParser extends Bas
                 retval = PDFOperator.getOperator( next );
                 if( next.equals( "BI" ) )
                 {
-                	PDFOperator beginImageOP = (PDFOperator)retval;
+                    PDFOperator beginImageOP = (PDFOperator)retval;
                     COSDictionary imageParams = new COSDictionary();
                     beginImageOP.setImageParameters( imageParams );
                     Object nextToken = null;
@@ -530,13 +530,13 @@ public class PDFStreamParser extends Bas
      * {@inheritDoc}
      */
     @Override
-    public void clearResources() 
+    public void clearResources()
     {
-    	super.clearResources();
-    	if (streamObjects != null)
-    	{
-    		streamObjects.clear();
-    		streamObjects = null;
-    	}
+        super.clearResources();
+        if (streamObjects != null)
+        {
+            streamObjects.clear();
+            streamObjects = null;
+        }
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Thu May 29 15:04:15 2014
@@ -1289,7 +1289,7 @@ public class COSWriter implements ICOSVi
      * @throws IOException If an error occurs while generating the data.
      */
     public void write(PDDocument doc) throws IOException
-	{
+    {
         Long idTime = doc.getDocumentId() == null ? System.currentTimeMillis() : 
                                                     doc.getDocumentId();
 

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/cos/TestCOSString.java Thu May 29 15:04:15 2014
@@ -20,11 +20,11 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 
-import org.apache.pdfbox.pdfwriter.COSWriter;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.pdfbox.pdfwriter.COSWriter;
+
 /**
  * This will test all of the filters in the PDFBox system.
  *
@@ -33,9 +33,9 @@ import junit.framework.TestSuite;
  */
 public class TestCOSString extends TestCOSBase
 {
-    private final static String ESC_CHAR_STRING =
+    private static final String ESC_CHAR_STRING =
             "( test#some) escaped< \\chars>!~1239857 ";
-    private final static String ESC_CHAR_STRING_PDF_FORMAT =
+    private static final String ESC_CHAR_STRING_PDF_FORMAT =
             "\\( test#some\\) escaped< \\\\chars>!~1239857 ";
 
     /**
@@ -48,6 +48,7 @@ public class TestCOSString extends TestC
         return new TestSuite(TestCOSString.class);
     }
 
+    @Override
     public void setUp()
     {
         testCOSBase = new COSString("test cos string");
@@ -229,6 +230,25 @@ public class TestCOSString extends TestC
 
             COSString escapedString = new COSString(ESC_CHAR_STRING);
             assertEquals(ESC_CHAR_STRING, escapedString.getString());
+
+            testStr = "Line1\nLine2\nLine3\n";
+            COSString lineFeedString = new COSString(testStr);
+            assertEquals(testStr, lineFeedString.getString());
+
+            //Same as previous but this time it is constructed incrementally (like in a dictionary)
+            lineFeedString = new COSString();
+            for (int i = 0; i < testStr.length(); i++)
+            {
+                lineFeedString.append(testStr.charAt(i));
+            }
+            assertEquals(testStr, lineFeedString.getString());
+
+            testStr = "Text\u2026"; //PDFBOX-1437
+            COSString pdfbox1437 = new COSString();
+            pdfbox1437.append(new byte[] {
+                    0x54, 0x65, 0x78, 0x74, (byte)(0x83 & 0xFF)
+            });
+            assertEquals(testStr, pdfbox1437.getString());
         }
         catch (IOException e)
         {

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1598316&r1=1598315&r2=1598316&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java Thu May 29 15:04:15 2014
@@ -162,6 +162,7 @@ public class PreflightParser extends Non
         }
     }
 
+    @Override
     public void parse() throws IOException
     {
         parse(Format.PDF_A1B);
@@ -326,6 +327,7 @@ public class PreflightParser extends Non
      * Same method than the {@linkplain PDFParser#parseXrefTable(long)} with additional controls : - EOL mandatory after
      * the 'xref' keyword - Cross reference subsection header uses single white space as separator - and so on
      */
+    @Override
     protected boolean parseXrefTable(long startByteOffset) throws IOException
     {
         if (pdfSource.peek() != 'x')
@@ -438,6 +440,7 @@ public class PreflightParser extends Non
      * Wraps the {@link NonSequentialPDFParser#parseCOSStream} to check rules on 'stream' and 'endstream' keywords.
      * {@link #checkStreamKeyWord()} and {@link #checkEndstreamKeyWord()}
      */
+    @Override
     protected COSStream parseCOSStream(COSDictionary dic, RandomAccess file) throws IOException
     {
         checkStreamKeyWord();
@@ -546,9 +549,22 @@ public class PreflightParser extends Non
     /**
      * Check that the hexa string contains only an even number of Hexadecimal characters. Once it is done, reset the
      * offset at the beginning of the string and call {@link BaseParser#parseCOSString()}
+     * @deprecated Not needed anymore. Use {@link #COSString()} instead. PDFBOX-1437
      */
+    @Override
+    @Deprecated
     protected COSString parseCOSString(boolean isDictionary) throws IOException
     {
+        return parseCOSString();
+    }
+    
+    /**
+     * Check that the hexa string contains only an even number of Hexadecimal characters. Once it is done, reset the
+     * offset at the beginning of the string and call {@link BaseParser#parseCOSString()}
+     */
+    @Override
+    protected COSString parseCOSString() throws IOException
+    {
         // offset reminder
         long offset = pdfSource.getOffset();
         char nextChar = (char) pdfSource.read();
@@ -560,7 +576,7 @@ public class PreflightParser extends Non
                 nextChar = (char) pdfSource.read();
                 if (nextChar != '>')
                 {
-                    if (Character.digit((char) nextChar, 16) >= 0)
+                    if (Character.digit(nextChar, 16) >= 0)
                     {
                         count++;
                     }
@@ -582,7 +598,7 @@ public class PreflightParser extends Non
 
         // reset the offset to parse the COSString
         pdfSource.seek(offset);
-        COSString result = super.parseCOSString(isDictionary);
+        COSString result = super.parseCOSString();
 
         if (result.getString().length() > MAX_STRING_LENGTH)
         {
@@ -594,6 +610,7 @@ public class PreflightParser extends Non
     /**
      * Call {@link BaseParser#parseDirObject()} check limit range for Float, Integer and number of Dictionary entries.
      */
+    @Override
     protected COSBase parseDirObject() throws IOException
     {
         COSBase result = super.parseDirObject();
@@ -632,6 +649,7 @@ public class PreflightParser extends Non
         return result;
     }
 
+    @Override
     protected COSBase parseObjectDynamically(int objNr, int objGenNr, boolean requireExistingNotCompressedObj)
             throws IOException
     {
@@ -845,6 +863,7 @@ public class PreflightParser extends Non
         return pdfObject.getObject();
     }
 
+    @Override
     protected int lastIndexOf(final char[] pattern, final byte[] buf, final int endOff)
     {
         int offset = super.lastIndexOf(pattern, buf, endOff);