diff -rupN itextpdf-5.4.4-sources-original/com/itextpdf/text/pdf/codec/TiffImage.java itextpdf-5.4.4-sources-patched/com/itextpdf/text/pdf/codec/TiffImage.java
--- itextpdf-5.4.4-sources-original/com/itextpdf/text/pdf/codec/TiffImage.java	2013-10-11 10:18:08.527136300 -0400
+++ itextpdf-5.4.4-sources-patched/com/itextpdf/text/pdf/codec/TiffImage.java	2013-09-14 17:54:16.000000000 -0400
@@ -66,11 +66,11 @@ import java.util.zip.Inflater;
  * @author Paulo Soares
  */
 public class TiffImage {
-
+    
     /** Gets the number of pages the TIFF document has.
      * @param s the file source
      * @return the number of pages
-     */
+     */    
     public static int getNumberOfPages(RandomAccessFileOrArray s) {
         try {
             return TIFFDirectory.getNumDirectories(s);
@@ -276,16 +276,16 @@ public class TiffImage {
     public static Image getTiffImage(RandomAccessFileOrArray s, boolean handleIncorrectImage, int page) {
         return getTiffImage(s, handleIncorrectImage, page, false);
     }
-
+    
     /** Reads a page from a TIFF image. Direct mode is not used.
      * @param s the file source
      * @param page the page to get. The first page is 1
      * @return the <CODE>Image</CODE>
-     */
+     */    
     public static Image getTiffImage(RandomAccessFileOrArray s, int page) {
         return getTiffImage(s, page, false);
     }
-
+    
     /** Reads a page from a TIFF image.
      * @param s the file source
      * @param page the page to get. The first page is 1
@@ -293,11 +293,11 @@ public class TiffImage {
      * by direct byte copying. It's faster but may not work
      * every time
      * @return the <CODE>Image</CODE>
-     */
+     */    
     public static Image getTiffImage(RandomAccessFileOrArray s, int page, boolean direct) {
         return getTiffImage(s, false, page, direct);
     }
-
+    
     protected static Image getTiffImageColor(TIFFDirectory dir, RandomAccessFileOrArray s) {
         try {
             int compression = (int)dir.getFieldAsLong(TIFFConstants.TIFFTAG_COMPRESSION);
@@ -420,8 +420,8 @@ public class TiffImage {
                     zip = new DeflaterOutputStream(stream);
             }
             if (compression == TIFFConstants.COMPRESSION_OJPEG) {
-
-                // Assume that the TIFFTAG_JPEGIFBYTECOUNT tag is optional, since it's obsolete and
+                
+                // Assume that the TIFFTAG_JPEGIFBYTECOUNT tag is optional, since it's obsolete and 
                 // is often missing
 
                 if ((!dir.isTagPresent(TIFFConstants.TIFFTAG_JPEGIFOFFSET))) {
@@ -434,15 +434,15 @@ public class TiffImage {
                     jpegLength = (int)dir.getFieldAsLong(TIFFConstants.TIFFTAG_JPEGIFBYTECOUNT) +
                         (int)size[0];
                 }
-
+                
                 byte[] jpeg = new byte[Math.min(jpegLength, (int)s.length() - jpegOffset)];
 
                 int posFilePointer = (int)s.getFilePointer();
-                posFilePointer = jpegOffset;
+                posFilePointer += jpegOffset;
                 s.seek(posFilePointer);
                 s.readFully(jpeg);
                 img = new Jpeg(jpeg);
-            }
+            } 
             else if (compression == TIFFConstants.COMPRESSION_JPEG) {
                 if (size.length > 1)
                     throw new IOException(MessageLocalization.getComposedMessage("compression.jpeg.is.only.supported.with.a.single.strip.this.image.has.1.strips", size.length));
@@ -477,7 +477,7 @@ public class TiffImage {
                 if (photometric == TIFFConstants.PHOTOMETRIC_RGB) {
                     img.setColorTransform(0);
                 }
-            }
+            } 
             else {
                 for (int k = 0; k < offset.length; ++k) {
                     byte im[] = new byte[(int)size[k]];
@@ -517,7 +517,7 @@ public class TiffImage {
                     rowsLeft -= rowsStrip;
                 }
                 if (bitsPerSample == 1 && samplePerPixel == 1 && photometric != TIFFConstants.PHOTOMETRIC_PALETTE) {
-                    img = Image.getInstance(w, h, false, Image.CCITTG4,
+                    img = Image.getInstance(w, h, false, Image.CCITTG4, 
                         photometric == TIFFConstants.PHOTOMETRIC_MINISBLACK ? Image.CCITT_BLACKIS1 : 0, g4.close());
                 }
                 else {
@@ -631,12 +631,12 @@ public class TiffImage {
         }
         return offset;
     }
-
+    
     // Uncompress packbits compressed image data.
     public static void decodePackbits(byte data[], byte[] dst) {
         int srcCount = 0, dstCount = 0;
         byte repeat, b;
-
+        
         try {
             while (dstCount < dst.length) {
                 b = data[srcCount++];
@@ -684,6 +684,6 @@ public class TiffImage {
                 uncompData[count] += uncompData[count - samplesPerPixel];
                 count++;
             }
-        }
+        }    
     }
 }
