You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ca...@apache.org on 2009/04/07 18:24:19 UTC

svn commit: r762834 - in /incubator/pdfbox/trunk: src/main/java/org/apache/pdfbox/ src/main/java/org/apache/pdfbox/examples/util/ src/main/java/org/apache/pdfbox/util/ src/test/java/org/apache/pdfbox/util/ test/input/

Author: carrier
Date: Tue Apr  7 16:24:19 2009
New Revision: 762834

URL: http://svn.apache.org/viewvc?rev=762834&view=rev
Log:
Patch for PDFBOX-449, which applies output encoding-specific normalization for text diacritics so that the accents are over and not next to the characters.  Patch by Justin LeFebvre and myself.

Modified:
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/ExtractText.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFHighlighter.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextNormalize.java
    incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java
    incubator/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
    incubator/pdfbox/trunk/test/input/Garcia2004_thesis.pdf-sorted.txt
    incubator/pdfbox/trunk/test/input/Garcia2004_thesis.pdf.txt
    incubator/pdfbox/trunk/test/input/cweb.pdf-sorted.txt
    incubator/pdfbox/trunk/test/input/cweb.pdf.txt

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/ExtractText.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/ExtractText.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/ExtractText.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/ExtractText.java Tue Apr  7 16:24:19 2009
@@ -213,7 +213,7 @@
                 }
                 else
                 {
-                    stripper = new PDFTextStripper();
+                    stripper = new PDFTextStripper(encoding);
                 }
                 stripper.setSortByPosition( sort );
                 stripper.setStartPage( startPage );

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java Tue Apr  7 16:24:19 2009
@@ -111,11 +111,11 @@
      */
     protected void processTextPosition( TextPosition text )
     {
-        System.out.println( "String[" + text.getX() + "," +
-                text.getY() + " fs=" + text.getFontSize() + " xscale=" +
-                text.getXScale() + " height=" + text.getHeight() + " space=" +
+        System.out.println( "String[" + text.getXDirAdj() + "," +
+                text.getYDirAdj() + " fs=" + text.getFontSize() + " xscale=" +
+                text.getXScale() + " height=" + text.getHeightDir() + " space=" +
                 text.getWidthOfSpace() + " width=" +
-                text.getWidth() + "]" + text.getCharacter() );
+                text.getWidthDirAdj() + "]" + text.getCharacter() );
     }
 
     /**

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/ICU4JImpl.java Tue Apr  7 16:24:19 2009
@@ -57,7 +57,7 @@
     }
 
     /**
-     * Normalize presentation forms of characters to the separate parts.
+     * Normalize presentation forms of characters to the separate parts. 
      * @see TextNormalize.normalizePres(String)
      * 
      * @param a_str String to normalize
@@ -74,45 +74,49 @@
             char c = a_str.charAt(i);
             if (((c >= 0xFB00) && (c <= 0xFDFF)) ||
                     ((c >= 0xFE70) && (c <= 0xFEFF)))	{
-                /* The following ligatures have a space in them
-                 * when they are decomposed. PDF files adjust for
-                 * this using TJ spacing, but currently a space
-                 * gets created in the word by the normalization.
-                 * The current fix is to hard code the decomposition
-                 * without the space.
-                 */
-                if(c == 0xFC5E){
-                    retStr += "\u064c\u0651";
-                }
-                else if(c == 0xFC5F){
-                    retStr += "\u064d\u0651";
-                }
-                else if(c == 0xFC60){
-                    retStr += "\u064e\u0651";
-                }
-                else if(c == 0xFC61){
-                    retStr += "\u064f\u0651";
-                }
-                else if(c == 0xFC62){
-                    retStr += "\u0650\u0651";
-                }
-                else if(c == 0xFC63){
-                    retStr += "\u0651\u0670";
-                }
                 /* Some fonts map U+FDF2 differently than the Unicode spec.
                  * They add an extra U+0627 character to compensate.  
                  * This removes the extra character for those fonts. */ 
-                else if((c == 0xFDF2) && (i > 0) && ((a_str.charAt(i-1) == 0x0627) || (a_str.charAt(i-1) == 0xFE8D))) {
+                if((c == 0xFDF2) && (i > 0) && ((a_str.charAt(i-1) == 0x0627) || (a_str.charAt(i-1) == 0xFE8D))) {
                     retStr += "\u0644\u0644\u0647";
                 }
                 else{
-                    retStr += Normalizer.normalize(c, Normalizer.NFKC); 
+                    /*
+                     * Trim because some decompositions have an extra space, such as
+                     * U+FC5E
+                     */
+                    retStr += Normalizer.normalize(c, Normalizer.NFKC).trim(); 
                 }
-            }      
+            }
             else {
                 retStr += a_str.charAt(i);
             }
         }
-        return retStr; 
+        return retStr;
+    }
+    /**
+     * Decomposes Diacritic characters to their combining forms
+     * 
+     * @param a_str String to be Normalized
+     * @return A Normalized String
+     */      
+    public String normalizeDiac(String a_str){
+        String retStr = "";
+        for (int i = 0; i < a_str.length(); i++) {
+            char c = a_str.charAt(i);
+            if(Character.getType(c) == Character.NON_SPACING_MARK 
+                    || Character.getType(c) == Character.MODIFIER_SYMBOL
+                    || Character.getType(c) == Character.MODIFIER_LETTER){
+                /*
+                 * Trim because some decompositions have an extra space, such as
+                 * U+00B4
+                 */
+                retStr += Normalizer.normalize(c, Normalizer.NFKC).trim();
+            }
+            else{
+                retStr += a_str.charAt(i);
+            }
+        }
+        return retStr;
     }
 }

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFHighlighter.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFHighlighter.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFHighlighter.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFHighlighter.java Tue Apr  7 16:24:19 2009
@@ -45,6 +45,7 @@
     private String[] searchedWords;
     private ByteArrayOutputStream textOS = null;
     private Writer textWriter = null;
+    private static final String encoding = "UTF-16";
 
     /**
      * Default constructor.
@@ -53,7 +54,7 @@
      */
     public PDFHighlighter() throws IOException
     {
-        super();
+        super(encoding);
         super.setLineSeparator( "" );
         super.setPageSeparator( "" );
         super.setWordSeparator( "" );
@@ -95,7 +96,7 @@
                                 //" mode=active " + */
                                 " version=2>\n<Highlight>\n");
         textOS = new ByteArrayOutputStream();
-        textWriter = new OutputStreamWriter( textOS, "UTF-16" );
+        textWriter = new OutputStreamWriter( textOS, encoding);
         writeText(pdDocument, textWriter);
         highlighterOutput.write("</Highlight>\n</Body>\n</XML>");
         highlighterOutput.flush();
@@ -108,7 +109,7 @@
     {
         textWriter.flush();
 
-        String page = new String( textOS.toByteArray(), "UTF-16" );
+        String page = new String( textOS.toByteArray(), encoding );
         textOS.reset();
         //page = page.replaceAll( "\n", "" );
         //page = page.replaceAll( "\r", "" );

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFText2HTML.java Tue Apr  7 16:24:19 2009
@@ -35,7 +35,6 @@
     private static final int INITIAL_PDF_TO_HTML_BYTES = 8192;
 
     private boolean onFirstPage = true;
-    private String encoding;
 
     /**
      * Constructor.

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/PDFTextStripper.java Tue Apr  7 16:24:19 2009
@@ -96,6 +96,7 @@
     protected String lineSeparator = System.getProperty("line.separator");
     private String pageSeparator = System.getProperty("line.separator");
     private String wordSeparator = " ";
+    protected String encoding;    // encoding that text will be written in (or null)
 
     /**
      * The stream to write the output to.
@@ -110,17 +111,22 @@
 
     /**
      * Instantiate a new PDFTextStripper object.  This object will load properties from
-     * Resources/PDFTextStripper.properties.
+     * Resources/PDFTextStripper.properties and will not do anything special to 
+     * convert the text to a more encoding-specific output.  
      * @throws IOException If there is an error loading the properties.
      */
     public PDFTextStripper() throws IOException
     {
         super( ResourceLoader.loadProperties( "Resources/PDFTextStripper.properties", true ) );
+        this.encoding = null;
+        normalize = new TextNormalize(this.encoding);
     }
 
+
     /**
      * Instantiate a new PDFTextStripper object.  Loading all of the operator mappings
-     * from the properties object that is passed in.
+     * from the properties object that is passed in.  Does not convert the text
+     * to more encoding-specific output.
      *
      * @param props The properties containing the mapping of operators to PDFOperator
      * classes.
@@ -130,6 +136,23 @@
     public PDFTextStripper( Properties props ) throws IOException
     {
         super( props );
+        this.encoding = null;
+        normalize = new TextNormalize(this.encoding);
+    }
+    /**
+     * Instantiate a new PDFTextStripper object. This object will load properties from
+     * Resources/PDFTextStripper.properties and will apply encoding-specific
+     * conversions to the output text.  
+     *
+     * @param encoding The encoding that the output will be written in.
+     *
+     * @throws IOException If there is an error reading the properties.
+     */
+    public PDFTextStripper( String encoding ) throws IOException
+    {
+        super( ResourceLoader.loadProperties( "Resources/PDFTextStripper.properties", true ));
+        this.encoding = encoding;
+        normalize = new TextNormalize(this.encoding);
     }
 
     /**
@@ -422,10 +445,6 @@
         float maxHeightForLine = -1;
         TextPosition lastPosition = null;
 
-        if (normalize == null) {
-            normalize = new TextNormalize();
-        }
-
         for( int i = 0; i < charactersByArticle.size(); i++)
         {
             List textList = (List)charactersByArticle.get( i );
@@ -658,8 +677,7 @@
 
             endArticle();
         }
-
-        writePageSeperator();;
+        writePageSeperator();
     }
 
     private boolean overlap( float y1, float height1, float y2, float height2 )
@@ -885,12 +903,12 @@
                  * This may not always be true. */
                 TextPosition previousTextPosition = (TextPosition)textList.get(textList.size()-1);
                 if(text.isDiacritic() && previousTextPosition.contains(text)){
-                    previousTextPosition.mergeDiacritic(text);
+                    previousTextPosition.mergeDiacritic(text, normalize);
                 }
                 /* If the previous TextPosition was the diacritic, merge it into this
                  * one and remove it from the list. */
                 else if(previousTextPosition.isDiacritic() && text.contains(previousTextPosition)){
-                    text.mergeDiacritic(previousTextPosition);
+                    text.mergeDiacritic(previousTextPosition, normalize);
                     textList.remove(textList.size()-1);
                     textList.add(text);
                 }

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextNormalize.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextNormalize.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextNormalize.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextNormalize.java Tue Apr  7 16:24:19 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.pdfbox.util;
 
+import java.util.HashMap;
+
 /**
  * This class allows a caller to normalize text in various ways.
  * It will load the ICU4J jar file if it is defined on the classpath.
@@ -23,12 +25,19 @@
  */
 public class TextNormalize {
     private ICU4JImpl icu4j = null;
+    private static final HashMap diacHash = new HashMap();
+    private String encoding;
 
-    public TextNormalize() {
+    /**
+     * 
+     * @param encoding The Encoding that the text will eventually be written as (or null)
+     */
+    public TextNormalize(String encoding) {
         findICU4J();
+        populateDiacHash();
+        this.encoding = encoding;
     }
 
-
     private void findICU4J() {
         // see if we can load the icu4j classes from the classpath
         try {
@@ -39,7 +48,47 @@
             icu4j = null;
         }
     }
-
+    /*
+     * Adds non-decomposing diacritics to the hash with their related
+     * combining character. These are values that the unicode spec claims
+     * are equivalent but are not mapped in the form NFKC normalization method.
+     * Determined by going through the Combining Diacritical Marks section of 
+     * the Unicode spec and identifying which characters are not mapped to by 
+     * the normalization. 
+     */
+    private void populateDiacHash(){
+        diacHash.put(new Integer(0x0060), "\u0300");
+        diacHash.put(new Integer(0x02CB), "\u0300");
+        diacHash.put(new Integer(0x0027), "\u0301");
+        diacHash.put(new Integer(0x02B9), "\u0301");
+        diacHash.put(new Integer(0x02CA), "\u0301");
+        diacHash.put(new Integer(0x005e), "\u0302");
+        diacHash.put(new Integer(0x02C6), "\u0302");
+        diacHash.put(new Integer(0x007E), "\u0303");
+        diacHash.put(new Integer(0x02C9), "\u0304");
+        diacHash.put(new Integer(0x00B0), "\u030A");
+        diacHash.put(new Integer(0x02BA), "\u030B");
+        diacHash.put(new Integer(0x02C7), "\u030C");
+        diacHash.put(new Integer(0x02C8), "\u030D");
+        diacHash.put(new Integer(0x0022), "\u030E");
+        diacHash.put(new Integer(0x02BB), "\u0312");
+        diacHash.put(new Integer(0x02BC), "\u0313");
+        diacHash.put(new Integer(0x0486), "\u0313");
+        diacHash.put(new Integer(0x055A), "\u0313");
+        diacHash.put(new Integer(0x02BD), "\u0314");
+        diacHash.put(new Integer(0x0485), "\u0314");
+        diacHash.put(new Integer(0x0559), "\u0314");
+        diacHash.put(new Integer(0x02D4), "\u031D");
+        diacHash.put(new Integer(0x02D5), "\u031E");
+        diacHash.put(new Integer(0x02D6), "\u031F");
+        diacHash.put(new Integer(0x02D7), "\u0320");
+        diacHash.put(new Integer(0x02B2), "\u0321");
+        diacHash.put(new Integer(0x02CC), "\u0329");
+        diacHash.put(new Integer(0x02B7), "\u032B");
+        diacHash.put(new Integer(0x02CD), "\u0331");
+        diacHash.put(new Integer(0x005F), "\u0332");
+        diacHash.put(new Integer(0x204E), "\u0359");
+    }
 
     /**
      * Takes a line of text in presentation order and converts it to logical order.
@@ -63,7 +112,7 @@
 
     /**
      * Normalize the presentation forms of characters in the string.
-     * For example, convert the single "fi" ligature to "f" and "i". 
+     * For example, convert the single "fi" ligature to "f" and "i".
      * 
      * @param a_str String to normalize
      * @return Normalized string (or original string if ICU4J library is not on classpath)
@@ -76,4 +125,35 @@
             return a_str;
         }
     }
+    
+    /**
+     * Normalize the diacritic, for example, 
+     * convert non-combining diacritic characters to their combining
+     * counterparts. 
+     * 
+     * @param a_str String to normalize 
+     * @return Normalized string (or original string if ICU4J library is not on classpath)
+     */
+    public String normalizeDiac(String a_str){
+        /*
+         * Unicode contains special combining forms of the diacritic characters
+         * and we want to use these. 
+         */
+        if(encoding != null && encoding.toUpperCase().startsWith("UTF")){
+            Integer c = new Integer(a_str.charAt(0));
+            // convert the characters not defined in the Unicode spec
+            if(diacHash.containsKey(c)){
+                return (String)diacHash.get(c);
+            }
+            else if (icu4j != null) {
+                return icu4j.normalizeDiac(a_str);
+            }
+            else {
+                return a_str;
+            }
+        }
+        else{
+            return a_str;
+        }
+    }
 }

Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/TextPosition.java Tue Apr  7 16:24:19 2009
@@ -451,8 +451,9 @@
      * contains() method to test if two objects overlap. 
      * 
      * @param diacritic TextPosition to merge into the current TextPosition.
+     * @param normalize Instance of TextNormalize class to be used to normalize diacritic
      */
-    public void mergeDiacritic (TextPosition diacritic)
+    public void mergeDiacritic (TextPosition diacritic, TextNormalize normalize)
     {
         if (diacritic.getCharacter().length() > 1)
             return;
@@ -476,7 +477,7 @@
              */
             if(diacXStart < currCharXStart && diacXEnd <= currCharXEnd){               
                 if(i == 0){
-                    insertDiacritic(i, diacritic);
+                    insertDiacritic(i, diacritic, normalize);
                 }
                 else{    
                     float distanceOverlapping1 = diacXEnd - currCharXStart;
@@ -486,10 +487,10 @@
                     float percentage2 = distanceOverlapping2/widths[i-1];
 
                     if(percentage1 >= percentage2){
-                        insertDiacritic(i, diacritic);
+                        insertDiacritic(i, diacritic, normalize);
                     }
                     else{
-                        insertDiacritic(i-1, diacritic);
+                        insertDiacritic(i-1, diacritic, normalize);
                     }
                 }
                 wasAdded = true;
@@ -497,20 +498,20 @@
             //diacritic completely covers this character and therefore we assume that
             //this is the character the diacritic belongs to
             else if(diacXStart < currCharXStart && diacXEnd > currCharXEnd){
-                insertDiacritic(i, diacritic);
+                insertDiacritic(i, diacritic, normalize);
                 wasAdded = true;
             }
             //Otherwise, The diacritic modifies this character because its completely
             //contained by the character width
             else if(diacXStart >= currCharXStart && diacXEnd <= currCharXEnd) {
-                insertDiacritic(i, diacritic);
+                insertDiacritic(i, diacritic, normalize);
                 wasAdded = true;   
             }
             /*
              * Last character in the TextPosition so we add diacritic to the end
              */
             else if(diacXStart >= currCharXStart && diacXEnd > currCharXEnd && i == (strLen - 1)){
-                insertDiacritic(i, diacritic);
+                insertDiacritic(i, diacritic, normalize);
                 wasAdded = true;
             }        
             /*
@@ -525,8 +526,9 @@
      * and updates the widths array to include the extra character width.
      * @param i current character
      * @param diacritic The diacritic TextPosition
+     * @param normalize Instance of TextNormalize class to be used to normalize diacritic
      */
-    private void insertDiacritic(int i, TextPosition diacritic){
+    private void insertDiacritic(int i, TextPosition diacritic, TextNormalize normalize){
         /* we add the diacritic to the right or left of the character
          * depending on the direction of the character.  Note that this
          * is only required because the text is currently stored in 
@@ -544,7 +546,7 @@
                 || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC)
                 || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING)
                 || (dir == Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE)) {
-            buf.append(diacritic.getCharacter());
+            buf.append(normalize.normalizeDiac(diacritic.getCharacter()));
             widths2[i] = 0;
             buf.append(str.charAt(i));
             widths2[i+1] = widths[i];
@@ -552,7 +554,7 @@
         else {
             buf.append(str.charAt(i));
             widths2[i] = widths[i];
-            buf.append(diacritic.getCharacter());
+            buf.append(normalize.normalizeDiac(diacritic.getCharacter()));
             widths2[i+1] = 0;
         }
 

Modified: incubator/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java (original)
+++ incubator/pdfbox/trunk/src/test/java/org/apache/pdfbox/util/TestTextStripper.java Tue Apr  7 16:24:19 2009
@@ -89,6 +89,7 @@
     private boolean bFail = false;
     private PDFTextStripper stripper = null;
     private PrintWriter log = null;
+    private final String encoding = "UTF-16LE";
 
     /**
      * Test class constructor.
@@ -100,7 +101,7 @@
     public TestTextStripper( String name ) throws IOException
     {
         super( name );
-        stripper = new PDFTextStripper();
+        stripper = new PDFTextStripper(encoding);
         stripper.setLineSeparator("\n");
     }
 
@@ -248,7 +249,7 @@
             os = new FileOutputStream(outFile);
             os.write( 0xFF );
             os.write( 0xFE );
-            writer = new OutputStreamWriter(os,"UTF-16LE");
+            writer = new OutputStreamWriter(os,encoding);
 
             //Allows for sorted tests 
             stripper.setSortByPosition(bSort);
@@ -270,9 +271,9 @@
             }
 
             LineNumberReader expectedReader =
-                new LineNumberReader(new InputStreamReader(new FileInputStream(expectedFile),"UTF-16LE"));
+                new LineNumberReader(new InputStreamReader(new FileInputStream(expectedFile), encoding));
             LineNumberReader actualReader =
-                new LineNumberReader(new InputStreamReader(new FileInputStream(outFile), "UTF-16LE"));
+                new LineNumberReader(new InputStreamReader(new FileInputStream(outFile), encoding));
 
             while (true)
             {

Modified: incubator/pdfbox/trunk/test/input/Garcia2004_thesis.pdf-sorted.txt
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/test/input/Garcia2004_thesis.pdf-sorted.txt?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/pdfbox/trunk/test/input/Garcia2004_thesis.pdf.txt
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/test/input/Garcia2004_thesis.pdf.txt?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/pdfbox/trunk/test/input/cweb.pdf-sorted.txt
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/test/input/cweb.pdf-sorted.txt?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/pdfbox/trunk/test/input/cweb.pdf.txt
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/test/input/cweb.pdf.txt?rev=762834&r1=762833&r2=762834&view=diff
==============================================================================
Binary files - no diff available.