I used this code and it worked.

    public static void convert4(File inputFile, File outputFile) {
        
        String filename = new String();
        String imagename = new String();
        Document document = new Document();
        
        try {
            
            PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(outputFile));
            
            document.open();
            
            PdfContentByte cb = writer.getDirectContent();
            
            SeekableStream s = new FileSeekableStream(inputFile);
            TIFFDecodeParam param = null;
            ImageDecoder dec =
ImageCodec.createImageDecoder("tiff",s,param);
            System.out.println("Number of pages in this Tiff: " +
dec.getNumPages());
            for (int imageToLoad = 0; imageToLoad < dec.getNumPages();
++imageToLoad) {
                PlanarImage im = new
NullOpImage(dec.decodeAsRenderedImage(imageToLoad), null,
OpImage.OP_IO_BOUND, null);
                System.out.println(im.toString());
                BufferedImage bufim = im.getAsBufferedImage();
                com.lowagie.text.Image image =
com.lowagie.text.Image.getInstance(bufim, null);
                image.setAbsolutePosition(0, 0);
                //image.scalePercent(20);
                cb.addImage(image);
                document.newPage();
            }
            
        }
        catch (DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch (IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        
        // step 5: we close the document
        document.close();
        
        System.out.println("finished creating: " + filename);
        System.exit(0);
        
    }

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Damien Collis (NSW) [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, October 28, 2002 22:53
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] tiff2pdf using iText
> 
> I have a tiff file that I cannot get imported into an itext PDF.  I have
> read the similar listing by 'Padmanabhan, Shobana', read through the
> discussions on the 'JAI-INTEREST archives' and tried converting the image
> (every which way) using JAI to 8bit, argb (BufferedImage.TYPE_4BYTE_ABGR),
> as yet, no success.
> 
> Could someone please supply a definitive response (with source code) to
> importing the file I have posted at the following address into an iText
> PDF document.
> 
> <http://www.users.bigpond.com/dcollis/4.tif> 
> If, in the mean time, I resolve my issues, look for a posting on tiff2pdf
> using iText here! 
> 
> Thanks in advance. 
> Damien. 
> 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to