Index: src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java
===================================================================
--- src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java	(revision 719304)
+++ src/main/java/org/apache/pdfbox/filter/ASCIIHexFilter.java	(working copy)
@@ -33,28 +33,58 @@
 public class ASCIIHexFilter implements Filter
 {
 
-    /**
-     * {@inheritDoc}
-     */
-    public void decode( InputStream compressedData, OutputStream result, COSDictionary options, int filterIndex ) throws IOException
-    {
-        int value =0;
-        int firstByte = 0;
-        int secondByte = 0;
-        while( (firstByte = compressedData.read()) != -1 )
-        {
-            value = REVERSE_HEX[firstByte] * 16;
-            secondByte = compressedData.read();
-            if( secondByte >= 0 )
-            {
-                value += REVERSE_HEX[ secondByte ];
-            }
-            result.write( value );
-        }
-        result.flush();
-    }
+	/**
+	  * Whitespace
+	  *   0  0x00  Null (NUL)
+	  *   9  0x09  Tab (HT)
+	  *  10  0x0A  Line feed (LF)
+	  *  12  0x0C  Form feed (FF)
+	  *  13  0x0D  Carriage return (CR)
+	  *  32  0x20  Space (SP)  
+	  */
+	protected boolean isWhitespace(int c) {
+		return c == 0 || c == 9 || c == 10 || c == 12 || c == 13 || c == 32;
+	}
+	   
+	protected boolean isEOD(int c) {
+		return (c == 62); // '>' - EOD
+	}
+	
+	/**
+	  * {@inheritDoc}
+	  */
+	public void decode(InputStream compressedData, OutputStream result, COSDictionary options, int filterIndex) throws IOException {
+		int value = 0;
+	    int firstByte = 0;
+	    int secondByte = 0;
+	    while ((firstByte = compressedData.read()) != -1) {
+	    	// always after first char
+	    	while(isWhitespace(firstByte))
+	    		firstByte = compressedData.read();
+	    	if(isEOD(firstByte))
+	    		break;
+	       
+	    	if(REVERSE_HEX[firstByte] == -1)
+	    		System.out.println("Invalid Hex Code; int: " + firstByte + " char: " + (char) firstByte);
+	    	value = REVERSE_HEX[firstByte] * 16;
+	    	secondByte = compressedData.read();
+	       
+	    	if(isEOD(secondByte)) {
+	    		// second value behaves like 0 in case of EOD
+	    		result.write(value);
+	    		break;
+	    	}
+	    	if(secondByte >= 0) {
+	    		if(REVERSE_HEX[secondByte] == -1)
+	    			System.out.println("Invalid Hex Code; int: " + secondByte + " char: " + (char) secondByte);
+	    		value += REVERSE_HEX[secondByte];
+	    	}
+	    	result.write(value);
+	    }
+	    result.flush();
+	}
 
-    private static final int[] REVERSE_HEX =
+	private static final int[] REVERSE_HEX =
     {
         -1, //0
         -1, //1
