The problem is that your file doesn't include the required StripByteCounts tag. In other words, the file is broken; that it can be opened by other tools has nothing to do with the quality of the file itself. I've added an hack to iText to be able to read this kind of files, get it from the CVS.
Paulo > -----Original Message----- > From: SeungHyun Park [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 02, 2006 5:39 AM > To: Paulo Soares > Subject: Re: Error when converting one-page tiff image to PDF. > > Thank you for your reply. > > I tested my tiff file by various methods and then found the > reason of error may be compression types. > > When I converted my tiff file to other tiff files by the > CCITT group 3 or group 4 with ACDSee and used them, my code > worked fine. But it didn't worked when i converted by other > compression types(none,lzw,jpeg and deflate). > > However, I found the post that iText supports many Tiff > compression types - no compression, packbits, lzw, deflate, > ccitt. But, my code works only at CCIT Group 3 and 4. > > I also found the post about error at large size tiffs. > > Most tiffs of mine are larger than 190K. but Converted tiffs > by CCIT Group 3 or 4 with ACDSee are smaller than 50K. > > If you could take a few minutes to analysis my tiff file, I > would really appreciate it. > > You can download it at snip... > > My code is almost similar to > http://itextdocs.lowagie.com/examples/com/lowagie/examples/obj > ects/images/tiff/Tiff2Pdf.java and you can consider it as my > code and I tested using iText.NET 1.3.4-1 and iTextSharp 3.0.10 > > > Thank you in advance for your help. > > Best regards, > > S. H. Park > > > > > 2006/1/28, Paulo Soares <[EMAIL PROTECTED]>: > > Works for me. Post your code. > > ----- Original Message ----- > From: "SeungHyun Park" < [EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, January 27, 2006 11:13 PM > Subject: [itextsharp-questions] Error when converting > one-page tiff image to > PDF. > > > I have been developed Tiff2PDF program using iTextSharp > and iText.NET. > > I made my program by referencing iText example codes. > > It works fine at multi-page tiff files, but error > occurred at one-page tiff > file. > > My code is based on the following sample code; > > > //============================================================ > =============================== > import com.lowagie.text.pdf.*; > import java.io.*; > import java.util.*; > import com.lowagie.text.pdf.codec.*; > > // reads all the tiffs in a directory and > sub-directories public class > read_tiffs { > > public static void main(String[] args) { > Document document = new Document(PageSize.A4, > 50, 50, 50, 50); > try { > PdfWriter writer = > PdfWriter.getInstance(document, new > FileOutputStream("c:\\many_tiffs.pdf")); > int pages = 0; > document.open(); > > PdfContentByte cb = writer.getDirectContent(); > ArrayList tif = new ArrayList(); > getAllTiffs(new File("c:\\"), tif); > for (int k = 0; k < tif.size(); ++k) { > RandomAccessFileOrArray ra = null; > String s = (String)tif.get(k); > int comps = 0; > try { > ra = new RandomAccessFileOrArray(s); > comps = TiffImage.getNumberOfPages(ra); > } > catch (Throwable e) { > System.out.println("Exception in " + > s + " " + > e.getMessage ()); > continue; > } > System.out.println("Processing " + s); > > for > (int c = 0; c < > comps; ++c) { > try { > Image img = > TiffImage.getTiffImage(ra, c + 1); > if (img != null) { > System.out.println("OK " + s > + " page " + (c + > 1)); > if (img.scaledWidth() > 500 || > img.scaledHeight() > > 700) > img.scaleToFit(500, 700); > img.setAbsolutePosition (20, 20); > document.add(new Paragraph(s > + " - page " + (c + > 1))); > cb.addImage(img); > document.newPage(); > ++pages; > } > } > catch (Throwable e) { > System.out.println("Exception " > + s + " page " + (c > + 1) + " " + e.getMessage()); > } > } > ra.close(); > } > if (pages == 0) > document.add(new Paragraph("No pages.")); > document.close(); > } > catch (Throwable e) { > e.printStackTrace(); > } > System.out.println("Done."); > > } > > public static void getAllTiffs(File dir, ArrayList tif) { > if (dir.isDirectory()) { > String[] children = dir.list(); > if (children == null) > return; > for (int i=0; i<children.length; i++) { > getAllTiffs(new File(dir, children[i]), tif); > } > } > else if (dir.getPath().toLowerCase().endsWith(".tif") || > dir.getPath().toLowerCase().endsWith(".tiff")) > { > tif.add(dir.getPath()); > } > } > } > '//=========================================================== > ========== > > > If I convert multi-page tiff images, they are converted > to PDF successfully. > > But, one-page tiff images cannot be converted to PDF > and error occurred at > "Image img = TiffImage.getTiffImage(ra, c + 1)" code of > above code with > following message: > > "The document has no pages." > > > I downloaded iTextSharp 3.0.10 sources and added the > reference of iTextSharp > project to my VS.NET project and set some breakpoints. > > Then, I found the position where error occurred; > > line 358 at TiffImage.cs: byte[] im = new byte[(int)size[k]]; > > At this line, size is null object, therefore error is > raised and finally it > is caught by try-catch block and error message as "The > document has no > pages." is wrote. > > I tried with iText.NET but it also doesn't work and > similar error occurs. > > > How can I fix this problem? > > If you could take a few minutes to answer my questions, > I would really > appreciate it. > Thank you in advance for your help. > > Best regards, > > S. H. Park > > > > > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions