Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] ArrayOutOfBounds when converting tiff to pdf

Olivier Ceulemans

2006-07-20


Hi all,
 
I tried to convert a tiff to pdf using itext.1.4.2. I got an ArrayOutOfBounds exception in the writeString method in the TIFFLZWDecoder.
I tried to open the tiff in several imaging programs (gimp, ms office imaging) and they displayed the image without complaining.
After searches on the mailing list I found a post back in 2003 with someone with the same problem. This person proposed a patch and it was answered it would be included.
Apparently, it didn't make it or there was a regression in itext (?).
 
I adapted the patch to itext 1.4.2:
 
    /**
     * Write out the string just uncompressed.
     */
    public void writeString(byte string[]) {
        // Fix for broken tiff files
        int max = uncompData.length-dstIndex;
        if (string.length<max)
            max = string.length;
 
        for (int i=0; i<max; i++) {
            uncompData[dstIndex++] = string[i];
        }
    }
 
And now it works...
 
Even if the tiff files are broken, it appears that broken files are correctly handled by other image readers. Even if this is not pretty and funny, I think itext could benefit from this patch.
 
And thank you for this very usefull library !
 
Regards,
Olivier C.
 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.