I found the example below in the mail archive.  The problem is that this
tiff is very large (pixel-wise about 7000x12000, but only 200k).  When I
try to load it (or similar images that actually work) with example 11, I
run out of memory, although I am doing other operations (combining two
images in this particular method).  Example 12 works fine on similar
sized images without using too much memory.  The code example below will
definitely not work (gave JVM 400MB and it still hit a
OutOfMemoryError).  Is there a method similar to Example 12 that can
load this image correctly without using massive amounts of memory?


    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);
    }


Thanks,
Aaron


-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 28, 2003 5:49 PM
To: Aaron Kelley; [EMAIL PROTECTED]
Subject: Re: [iText-questions] Bad PDF generated on large tiff

Example 11 may have problems due to a bug in JAI and example 12 only
reads
the first band of the tiff. I've posted code in the mailing list to fix
this, do a search in
http://www.mail-archive.com/itext-questions@lists.sourceforge.net/ for
"jai".

Best Regards,
Paulo Soares

----- Original Message -----
From: "Aaron Kelley" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 28, 2003 21:47
Subject: [iText-questions] Bad PDF generated on large tiff


> I have a rather large tiff file that I am trying to place in a PDF.  I
> have been using iText for some time with many other tiff images and
have
> had minimal problems.  The compression for this particular tiff is the
> same as other tiff images that are slightly smaller and work fine.  I
> have run into problems before with iText and large tiff files, but I
> have found workarounds.  This however is very odd in that no
exceptions
> are ever being thrown and the PDF that is generated is only a few
> kilobytes.  I can send the tiff out to anyone who is interested in
> looking at it (its 200k so I did not want to send it to the entire
> list).  Both iText example classes Chap0611 and Chap0612 fail to
create
> a valid PDF from this tiff.  I tried this with the latest version of
> iText and still have problems.  I would appreciate any thoughts anyone
> might have.
>
> Aaron Kelley | Software Developer
> Eagle Computer Systems | Colorado Division
>
> Phone: 303.986.1962
> Cell: 303.901.7634
> Email:  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
>
>



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to