You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/12/12 05:39:38 UTC

svn commit: r1644828 [2/2] - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/contentstream/ pdfbox/src/main/java/org/apache/pdfbox/cos/ pdfbox/src/main/java/org/apache/pdfbox/encoding/ pdfbox/src/main/java/org/apache/pdfbox/filter/ pdfbox/src/...

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java Fri Dec 12 04:39:37 2014
@@ -474,8 +474,7 @@ public final class StandardSecurityHandl
                 md.update( document.getDocument().toString().getBytes() );
 
                 byte[] id = md.digest( this.toString().getBytes("ISO-8859-1") );
-                COSString idString = new COSString();
-                idString.append( id );
+                COSString idString = new COSString(id);
 
                 idArray = new COSArray();
                 idArray.add( idString );

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDictionary.java Fri Dec 12 04:39:37 2014
@@ -91,8 +91,8 @@ public class FDFDictionary implements CO
                     COSArray ids = new COSArray();
                     String original = child.getAttribute( "original" );
                     String modified = child.getAttribute( "modified" );
-                    ids.add( COSString.createFromHexString( original ) );
-                    ids.add( COSString.createFromHexString( modified ) );
+                    ids.add( COSString.parseHex( original ) );
+                    ids.add( COSString.parseHex( modified ) );
                     setID( ids );
                 }
                 else if( child.getTagName().equals( "fields" ) )
@@ -157,8 +157,8 @@ public class FDFDictionary implements CO
         {
             COSString original = (COSString)ids.getObject( 0 );
             COSString modified = (COSString)ids.getObject( 1 );
-            output.write( "<ids original=\"" + original.getHexString() + "\" " );
-            output.write( "modified=\"" + modified.getHexString() + "\" />\n");
+            output.write( "<ids original=\"" + original.toHexString() + "\" " );
+            output.write( "modified=\"" + modified.toHexString() + "\" />\n");
         }
         List<FDFField> fields = getFields();
         if( fields != null && fields.size() > 0 )

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java Fri Dec 12 04:39:37 2014
@@ -358,7 +358,7 @@ public class PDSignature implements COSO
         }
         fis.close();
 
-        return COSString.createFromHexString(byteOS.toString()).getBytes();
+        return COSString.parseHex(byteOS.toString()).getBytes();
     }
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java Fri Dec 12 04:39:37 2014
@@ -109,13 +109,7 @@ public class PDNamedDestination extends
      */
     public void setNamedDestination( String dest ) throws IOException
     {
-        if( namedDestination instanceof COSString )
-        {
-            COSString string = ((COSString)namedDestination);
-            string.reset();
-            string.append( dest.getBytes("ISO-8859-1") );
-        }
-        else if( dest == null )
+        if (dest == null)
         {
             namedDestination = null;
         }
@@ -124,5 +118,4 @@ public class PDNamedDestination extends
             namedDestination = new COSString( dest );
         }
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAppearanceString.java Fri Dec 12 04:39:37 2014
@@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -35,6 +36,7 @@ import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.cos.COSString;
 import org.apache.pdfbox.pdfparser.PDFStreamParser;
+import org.apache.pdfbox.pdfwriter.COSWriter;
 import org.apache.pdfbox.pdfwriter.ContentStreamWriter;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
@@ -58,7 +60,6 @@ import org.apache.pdfbox.contentstream.o
  */
 public final class PDAppearanceString
 {
-
     private static final Log LOG = LogFactory.getLog(PDAppearanceString.class);
 
     private final PDVariableText parent;
@@ -311,7 +312,7 @@ public final class PDAppearanceString
     }
 
     private void insertGeneratedAppearance(PDAnnotationWidget fieldWidget, OutputStream output,
-            PDFont pdFont, List<Object> tokens, PDAppearanceStream appearanceStream)
+            PDFont font, List<Object> tokens, PDAppearanceStream appearanceStream)
             throws IOException
     {
         PrintWriter printWriter = new PrintWriter(output, true);
@@ -329,7 +330,7 @@ public final class PDAppearanceString
                     daString.getBytes("ISO-8859-1")));
             daParser.parse();
             List<Object> daTokens = daParser.getTokens();
-            fontSize = calculateFontSize(pdFont, boundingBox, tokens, daTokens);
+            fontSize = calculateFontSize(font, boundingBox, tokens, daTokens);
             int fontIndex = daTokens.indexOf(Operator.getOperator("Tf"));
             if (fontIndex != -1)
             {
@@ -347,7 +348,7 @@ public final class PDAppearanceString
         float paddingLeft = Math.max(2, Math.round(4 * borderEdge.getLowerLeftX()));
         float paddingRight = Math.max(2,
                 Math.round(4 * (boundingBox.getUpperRightX() - borderEdge.getUpperRightX())));
-        float verticalOffset = getVerticalOffset(boundingBox, pdFont, fontSize, tokens);
+        float verticalOffset = getVerticalOffset(boundingBox, font, fontSize, tokens);
 
         // Acrobat shifts the value so it aligns to the bottom if
         // the font's caps are larger than the height of the borderEdge
@@ -359,14 +360,14 @@ public final class PDAppearanceString
 
         if (fontHeight + 2 * borderEdge.getLowerLeftX() > borderEdge.getHeight())
         {
-            verticalOffset = pdFont.getBoundingBox().getHeight() / 1000 * fontSize
+            verticalOffset = font.getBoundingBox().getHeight() / 1000 * fontSize
                     - borderEdge.getHeight();
         }
 
         float leftOffset = 0f;
 
         // Acrobat aligns left regardless of the quadding if the text is wider than the remaining width
-        float stringWidth = (pdFont.getStringWidth(value) / 1000) * fontSize;
+        float stringWidth = (font.getStringWidth(value) / 1000) * fontSize;
         int q = getQ();
         if (q == PDTextField.QUADDING_LEFT
                 || stringWidth > borderEdge.getWidth() - paddingLeft - paddingRight)
@@ -390,20 +391,25 @@ public final class PDAppearanceString
 
         printWriter.println(leftOffset + " " + verticalOffset + " Td");
 
-        // add the value as hex string to deal with non ISO-8859-1 data values
+        // show the text
         if (!isMultiLineValue(value) || stringWidth > borderEdge.getWidth() - paddingLeft -
                 paddingRight)
         {
-            printWriter.println("<" + new COSString(value).getHexString() + "> Tj");
+            printWriter.print("<");
+            printWriter.flush();
+            COSWriter.writeString(value.getBytes(Charset.forName("ISO-8859-1")), output); // todo: use font's encoding
+            printWriter.println("> Tj");
         }
         else
         {
             String[] paragraphs = value.split("\n");
             for (int i = 0; i < paragraphs.length; i++)
             {
-                boolean lastLine = i == (paragraphs.length - 1);
-                String endingTag = lastLine ? "> Tj\n" : "> Tj 0 -13 Td";
-                printWriter.print("<" + new COSString(paragraphs[i]).getHexString() + endingTag);
+                boolean lastLine = i == paragraphs.length - 1;
+                printWriter.print("<");
+                printWriter.flush();
+                COSWriter.writeString(value.getBytes(Charset.forName("ISO-8859-1")), output); // todo: use font's encoding
+                printWriter.println(lastLine ? "> Tj\n" : "> Tj 0 -13 Td");
             }
         }
         printWriter.println("ET");

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Charsets.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Charsets.java?rev=1644828&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Charsets.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Charsets.java Fri Dec 12 04:39:37 2014
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.util;
+
+import java.nio.charset.Charset;
+
+/**
+ * Utility class providing common Charsets used in PDF.
+ *
+ * @author John Hewson
+ */
+public class Charsets
+{
+    private Charsets() {}
+
+    /*** ASCII charset */
+    public static final Charset US_ASCII = Charset.forName("US-ASCII");
+
+    /*** UTF-16BE charset */
+    public static final Charset UTF_16BE = Charset.forName("UTF-16BE");
+
+    /*** UTF-16LE charset */
+    public static final Charset UTF_16LE = Charset.forName("UTF-16LE");
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Charsets.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java?rev=1644828&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java (added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java Fri Dec 12 04:39:37 2014
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.util;
+
+/**
+ * Utility functions for hex encoding.
+ *
+ * @author John Hewson
+ */
+public class Hex
+{
+    private Hex() {}
+
+    /**
+     * Returns a hex string of the given byte.
+     */
+    public static String getString(byte b)
+    {
+        return Integer.toHexString(0x100 | b & 0xff).substring(1).toUpperCase();
+    }
+
+    /**
+     * Returns the bytes corresponding to the ASCII hex encoding of the given byte.
+     */
+    public static byte[] getBytes(byte b)
+    {
+        return getString(b).getBytes(Charsets.US_ASCII);
+    }
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/Hex.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1644828&r1=1644827&r2=1644828&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 Fri Dec 12 04:39:37 2014
@@ -66,59 +66,16 @@ public class TestCOSString extends TestC
     }
 
     /**
-     * Tests the public static members within the class that are purely PDF format string objects 
-     * like open/closing strings, escape characters etc...
-     */
-    public void testStaticMembers()
-    {
-        stringByteArrayComparison("(", COSString.STRING_OPEN);
-        stringByteArrayComparison(")", COSString.STRING_CLOSE);
-        stringByteArrayComparison("<", COSString.HEX_STRING_OPEN);
-        stringByteArrayComparison(">", COSString.HEX_STRING_CLOSE);
-        stringByteArrayComparison("\\", COSString.ESCAPE);
-        stringByteArrayComparison("\\r", COSString.CR_ESCAPE);
-        stringByteArrayComparison("\\n", COSString.LF_ESCAPE);
-        stringByteArrayComparison("\\t", COSString.HT_ESCAPE);
-        stringByteArrayComparison("\\b", COSString.BS_ESCAPE);
-        stringByteArrayComparison("\\f", COSString.FF_ESCAPE);
-    }
-
-    /**
-     * Helper method for comparing a string to it's PDF byte array.
-     * 
-     * @param expected the String expected
-     * @param member the byte array being tested
-     */
-    private void stringByteArrayComparison(String expected, byte[] member)
-    {
-        byte[] expectedBytes = null;
-        try
-        {
-            expectedBytes = expected.getBytes("ISO-8859-1");
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            fail("ISO-8859-1 encoding threw an exception: " + e.getMessage());
-        }
-        testByteArrays(expectedBytes, member);
-    }
-
-    /**
      * Test setForceHexForm() and setForceLiteralForm() - tests these two methods do enforce the
      * different String output forms within PDF. 
      */
     public void testSetForceHexLiteralForm()
     {
         String inputString = "Test with a text and a few numbers 1, 2 and 3";
-        String pdfLiteral = "(" + inputString + ")";
         String pdfHex = "<" + createHex(inputString) + ">";
         COSString cosStr = new COSString(inputString);
-        cosStr.setForceLiteralForm(true);
-        writePDFTests(pdfLiteral, cosStr);
         cosStr.setForceHexForm(true);
         writePDFTests(pdfHex, cosStr);
-        cosStr.setForceLiteralForm(true);
-        writePDFTests(pdfLiteral, cosStr);
 
         COSString escStr = new COSString(ESC_CHAR_STRING);
         writePDFTests("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", escStr);
@@ -138,7 +95,7 @@ public class TestCOSString extends TestC
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         try
         {
-            testSubj.writePDF(outStream);
+            COSWriter.writeString(testSubj, outStream);
         }
         catch (IOException e)
         {
@@ -148,20 +105,18 @@ public class TestCOSString extends TestC
     }
 
     /**
-     * Test createFromHexString() - tests that the proper String is created from a hex string input.
+     * Test parseHex() - tests that the proper String is created from a hex string input.
      */
-    public void testCreateFromHexString()
+    public void testFromHex()
     {
         String expected = "Quick and simple test";
         String hexForm = createHex(expected);
         try
         {
-            COSString test1 = COSString.createFromHexString(hexForm);
+            COSString test1 = COSString.parseHex(hexForm);
             writePDFTests("(" + expected + ")", test1);
-            COSString test2 = COSString.createFromHexString(createHex(ESC_CHAR_STRING));
+            COSString test2 = COSString.parseHex(createHex(ESC_CHAR_STRING));
             writePDFTests("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", test2);
-            COSString test3 = COSString.createFromHexString(hexForm + "xx", true);
-            writePDFTests("(" + expected + "?)", test3);
         }
         catch (IOException e)
         {
@@ -169,7 +124,7 @@ public class TestCOSString extends TestC
         }
         try
         {
-            COSString.createFromHexString(hexForm + "xx", false);
+            COSString.parseHex(hexForm + "xx");
             fail("Should have thrown an IOException here");
         }
         catch (IOException e)
@@ -196,36 +151,25 @@ public class TestCOSString extends TestC
         String expected = "Test subject for testing getHex";
         COSString test1 = new COSString(expected);
         String hexForm = createHex(expected);
-        assertEquals(hexForm, test1.getHexString());
-        test1.setForceLiteralForm(true);
-        assertEquals(hexForm, test1.getHexString());
+        assertEquals(hexForm, test1.toHexString());
         COSString escCS = new COSString(ESC_CHAR_STRING);
         // Not sure whether the escaped characters should be escaped or not, presumably since 
         // writePDF() gives you the proper formatted text, getHex() should ONLY convert to hex. 
-        assertEquals(createHex(ESC_CHAR_STRING), escCS.getHexString());
+        assertEquals(createHex(ESC_CHAR_STRING), escCS.toHexString());
     }
 
     /**
-     * Test getString() - ensure string are returned in the correct format.
+     * Test testGetString() - ensure getString() are returned in the correct format.
      */
     public void testGetString()
     {
-        COSString nullStr = new COSString();
-        assertEquals("", nullStr.getString());
         try
         {
             String testStr = "Test subject for getString()";
             COSString test1 = new COSString(testStr);
             assertEquals(testStr, test1.getString());
 
-            String appendedStr = "appended text";
-            test1.append(appendedStr.getBytes());
-            assertEquals(testStr + appendedStr, test1.getString());
-
-            test1.append(ESC_CHAR_STRING.getBytes());
-            assertEquals(testStr + appendedStr + ESC_CHAR_STRING, test1.getString());
-
-            COSString hexStr = COSString.createFromHexString(createHex(testStr));
+            COSString hexStr = COSString.parseHex(createHex(testStr));
             assertEquals(testStr, hexStr.getString());
 
             COSString escapedString = new COSString(ESC_CHAR_STRING);
@@ -234,56 +178,6 @@ public class TestCOSString extends TestC
             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)
-        {
-            fail("IOException thrown: " + e.getMessage());
-        }
-    }
-
-    /**
-     * Test append(int) and append(byte[]) - test both code paths. 
-     */
-    public void testAppend()
-    {
-        try
-        {
-            // Mostly tested in testGetString()
-            COSString testSubj = new COSString();
-            StringBuilder sb = new StringBuilder();
-            assertEquals(sb.toString(), testSubj.getString());
-            // Arbitrary int but makes it easy to test
-            testSubj.append('a');
-            sb.append("a");
-            assertEquals(sb.toString(), testSubj.getString());
-            testSubj.append(ESC_CHAR_STRING.getBytes());
-            sb.append(ESC_CHAR_STRING);
-            assertEquals(sb.toString(), testSubj.getString());
-            try
-            {
-                testSubj.append(null);
-                assertEquals(sb.toString(), testSubj.getString());
-                fail("NullPointerException not thrown.");
-            }
-            catch (NullPointerException e)
-            {
-                // PASS
-            }
         }
         catch (IOException e)
         {
@@ -292,18 +186,6 @@ public class TestCOSString extends TestC
     }
 
     /**
-     * Test reset() - tests that the internal buffer is reset. Not a great deal to test here...
-     */
-    public void testReset()
-    {
-        String str = "This string is going to be reset";
-        COSString testSubj = new COSString(str);
-        assertEquals(str, testSubj.getString());
-        testSubj.reset();
-        assertEquals("", testSubj.getString());
-    }
-
-    /**
      * Test getBytes() - again not much to test, just ensure the proper byte array is returned.
      */
     public void testGetBytes()
@@ -365,11 +247,11 @@ public class TestCOSString extends TestC
         
         // Test the writePDF method to ensure that the Strings are correct when written into PDF.
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        stringAscii.writePDF(out);
-        assertEquals("("+textAscii+")", new String(out.toByteArray(), "ASCII"));
+        COSWriter.writeString(stringAscii, out);
+        assertEquals("(" + textAscii + ")", new String(out.toByteArray(), "ASCII"));
         
         out.reset();
-        string8Bit.writePDF(out);
+        COSWriter.writeString(string8Bit, out);
         StringBuffer hex = new StringBuffer();
         for(char c : text8Bit.toCharArray()) {
            hex.append( Integer.toHexString(c).toUpperCase() );
@@ -377,7 +259,7 @@ public class TestCOSString extends TestC
         assertEquals("<"+hex.toString()+">", new String(out.toByteArray(), "ASCII"));
         
         out.reset();
-        stringHighBits.writePDF(out);
+        COSWriter.writeString(stringHighBits, out);
         hex = new StringBuffer();
         hex.append("FEFF"); // Byte Order Mark
         for(char c : textHighBits.toCharArray()) {
@@ -437,12 +319,6 @@ public class TestCOSString extends TestC
             assertFalse(y1 == null);
             assertFalse(z1 == null);
             assertFalse(x2 == null);
-
-            // Also check other state
-            COSString y2 = new COSString("Test");
-            y2.setForceLiteralForm(true);
-            assertFalse(y2.equals(x2));
-            assertTrue(y2.equals(x1));
         }
     }
 
@@ -458,8 +334,6 @@ public class TestCOSString extends TestC
         assertTrue(str1.hashCode() == str3.hashCode());
         str3.setForceHexForm(true);
         assertFalse(str1.hashCode() == str3.hashCode());
-        str3.setForceLiteralForm(true);
-        assertTrue(str1.hashCode() == str3.hashCode());
     }
 
     /**
@@ -468,11 +342,11 @@ public class TestCOSString extends TestC
      */
     public void testCompareFromHexString() throws IOException
     {
-        COSString test1 = COSString.createFromHexString("000000FF000000");
-        COSString test2 = COSString.createFromHexString("000000FF00FFFF");
+        COSString test1 = COSString.parseHex("000000FF000000");
+        COSString test2 = COSString.parseHex("000000FF00FFFF");
         assertEquals(test1, test1);
         assertEquals(test2, test2);
-        assertFalse(test1.getHexString().equals(test2.getHexString()));
+        assertFalse(test1.toHexString().equals(test2.toHexString()));
         assertFalse(Arrays.equals(test1.getBytes(), test2.getBytes()));
         assertFalse(test1.equals(test2));
         assertFalse(test2.equals(test1));

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=1644828&r1=1644827&r2=1644828&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 Fri Dec 12 04:39:37 2014
@@ -809,8 +809,7 @@ public class PreflightParser extends Non
                 if (objstmBaseObj instanceof COSStream)
                 {
                     // parse object stream
-                    PDFObjectStreamParser parser = new PDFObjectStreamParser((COSStream) objstmBaseObj, document,
-                            forceParsing);
+                    PDFObjectStreamParser parser = new PDFObjectStreamParser((COSStream) objstmBaseObj, document);
                     parser.parse();
 
                     // get set of object numbers referenced for this object stream

Modified: pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java (original)
+++ pdfbox/trunk/preflight/src/test/java/org/apache/pdfbox/preflight/utils/TestCOSUtils.java Fri Dec 12 04:39:37 2014
@@ -221,7 +221,7 @@ public class TestCOSUtils
 
         IOCOSDocument(File scratchDir) throws IOException
         {
-            super(scratchDir, false, true);
+            super(scratchDir, true);
         }
 
         @Override

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java?rev=1644828&r1=1644827&r2=1644828&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java Fri Dec 12 04:39:37 2014
@@ -51,9 +51,7 @@ public class ExtractText
     private static final String IGNORE_BEADS = "-ignoreBeads";
     private static final String DEBUG = "-debug";
     // jjb - added simple HTML output
-    private static final String HTML = "-html";  
-    // enables pdfbox to skip corrupt objects
-    private static final String FORCE = "-force"; 
+    private static final String HTML = "-html";
 
     /*
      * debug flag
@@ -164,10 +162,6 @@ public class ExtractText
             {
                 toConsole = true;
             }
-            else if( args[i].equals( FORCE ) )
-            {
-                force = true;
-            }
             else
             {
                 if( pdfFile == null )
@@ -225,7 +219,6 @@ public class ExtractText
                 {
                     stripper = new PDFTextStripper();
                 }
-                stripper.setForceParsing( force );
                 stripper.setSortByPosition( sort );
                 stripper.setShouldSeparateByBeads( separateBeads );
                 stripper.setStartPage( startPage );
@@ -334,7 +327,6 @@ public class ExtractText
             "  -html                        Output in HTML format instead of raw text\n" +
             "  -sort                        Sort the text before writing\n" +
             "  -ignoreBeads                 Disables the separation by beads\n" +
-            "  -force                       Enables pdfbox to ignore corrupt objects\n" +
             "  -debug                       Enables debug output about the time consumption of every stage\n" +
             "  -startPage <number>          The first page to start extraction(1 based)\n" +
             "  -endPage <number>            The last page to extract(inclusive)\n" +