The example only works with single strip tiffs. With multiple strip you have to extract each strip as an image and assemble the images in the pdf. This is a way to do it:
public static void convert2(File inputFile, File outputFile) { Document document = new Document(PageSize.LETTER, 0, 0, 0, 0); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outputFile)); SeekableStream s = new FileSeekableStream(inputFile); TIFFDirectory dir = new TIFFDirectory(s, 0); long IFDOffset = dir.getIFDOffset(); document.open(); PdfContentByte cb = writer.getDirectContent(); while (IFDOffset != 0L) { System.err.println("entering loop"); dir = new TIFFDirectory(s, IFDOffset, 0); IFDOffset = dir.getNextIFDOffset(); long h = dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_LENGTH); long w = dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_WIDTH); long rowsStrip = dir.getFieldAsLong(TIFFImageDecoder.TIFF_ROWS_PER_STRIP); TIFFField field = dir.getField(TIFFImageDecoder.TIFF_STRIP_OFFSETS); long offset[]; if (field.getType() == TIFFField.TIFF_LONG) offset = field.getAsLongs(); else { // must be short short temp[] = field.getAsShorts(); offset = new long[temp.length]; for (int k = 0; k < temp.length; ++k) offset[k] = temp[k]; } field = dir.getField(TIFFImageDecoder.TIFF_STRIP_BYTE_COUNTS); long size[]; if (field.getType() == TIFFField.TIFF_LONG) size = field.getAsLongs(); else { // must be short short temp[] = field.getAsShorts(); size = new long[temp.length]; for (int k = 0; k < temp.length; ++k) size[k] = temp[k]; } boolean reverse = false; if (dir.isTagPresent(TIFFImageDecoder.TIFF_FILL_ORDER)) reverse = (dir.getFieldAsLong(TIFFImageDecoder.TIFF_FILL_ORDER) == 2L); int compression = (int) dir.getFieldAsLong(TIFFImageDecoder.TIFF_COMPRESSION); switch (compression) { case TIFFImage.COMP_FAX_G3_1D: System.err.println("TIFFImage.COMP_FAX_G3_1D"); compression = Image.CCITTG3_1D; break; case TIFFImage.COMP_FAX_G3_2D: System.err.println("TIFFImage.COMP_FAX_G3_2D"); compression = Image.CCITTG3_1D; if (dir.isTagPresent(TIFFImageDecoder.TIFF_T4_OPTIONS)) { if (((int) dir.getFieldAsLong(TIFFImageDecoder.TIFF_T4_OPTIONS) & 1) != 0) compression = Image.CCITTG3_2D; } break; case TIFFImage.COMP_FAX_G4_2D: System.err.println("TIFFImage.COMP_FAX_G4_2D"); compression = Image.CCITTG4; break; default: throw new Exception("Compression type " + compression + " not supported"); } long rowsLeft = h; for (int k = 0; k < offset.length; ++k) { byte im[] = new byte[(int) size[k]]; s.seek(offset[k]); s.readFully(im); Image img = Image.getInstance((int) w, (int) Math.min(rowsStrip, rowsLeft), reverse, compression, 0, im); rowsLeft -= rowsStrip; img.scalePercent(72f / 200f * 100); document.add(img); } boolean result = document.newPage(); } document.close(); } catch (Exception de) { de.printStackTrace(); } } You can also use the example Chap0611.java although it's slower and the memory usage is higher. The final pdf size is the same. Best Regards, Paulo Soares > -----Original Message----- > From: Elamathi Sambandam [SMTP:[EMAIL PROTECTED]] > Sent: Thursday, May 02, 2002 17:16 > To: [EMAIL PROTECTED] > Subject: [iText-questions] itext sample for tiff(G3) to pdf > > Hi > > I am using itext to convert tiff to pdf files. > I am using sample (chap0612 ) given by itext. I just changed the > filename to my tiff file name > It converts to PDF. When i opened the pdf in acrobat it says "read less > image data than expected". > The tiff file has G3 format with COMP_FAX_G3_2D compression. > Should i do anything more that is not given in the sample to convert > tiff files of G3 with COMP_FAX_G3_2D > > Thank you > regards > Mathi > > > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions