Hi,

Could anyone please help me in this regard. I am trying to convert some of the tiff files into PDF and I get the following exceptions.

java.lang.IllegalArgumentException: Bad endness tag (not 0x4949 or 0x4d4d).(For only one *.tif file)

java.lang.RuntimeException: Decoding of old style JPEG-in-TIFF data is not supported.(For a few *.tif files)

java.lang.error: All fill bits preceding EOL code must be 0.(For a few *.tif files)

This is the code which is converting the tif to PDF:

File file = new File(filePath+fileName);
SeekableStream s = new FileSeekableStream(file);

TIFFDecodeParam param = null;

ImageDecoder dec = ImageCodec.createImageDecoder("tiff", s, param);

int total = dec.getNumPages();

PdfContentByte cb = writer.getDirectContent();

for (int k = 0; k < total; ++k) {
     RenderedImage ri = dec.decodeAsRenderedImage(k);
     Raster ra = ri.getData();
     BufferedImage bi = new BufferedImage(ri.getColorModel(),
     Raster.createWritableRaster(ri.getSampleModel(), ra.getDataBuffer(), null), false, new Hashtable());
     Image img = Image.getInstance(bi, null, true);
     img.scalePercent(72f / 300f * 100);
     img.setAbsolutePosition(0, 0);
     cb.addImage(img);
     document.newPage();
}

Could anyone please tell me what's wrong with the tif formats and what type of tif should I use for successful conversion?

Thanks and Regards,
Rajesh.S



Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site

Reply via email to