Thanks, If create the New *RandomAccessFileOrArray *inside the “For” loop
I'm not getting* EOF *error.

They way I'm using its correct? Or any other approach is available?



Here is my code
-----------------------
 RandomAccessFileOrArray ra = new RandomAccessFileOrArray(
inputTiffFile);
int pages = TiffImage.getNumberOfPages(ra);
ra.close();
for (int c = 0; c < pages; ++c) {
*RandomAccessFileOrArray raf = new RandomAccessFileOrArray(
inputTiffFile);
*Image tiff1 = TiffImage.getTiffImage(raf, c + 1);
if (tiff1.getScaledWidth() > 500
|| tiff1.getScaledHeight() > 700) {
tiff1.scaleToFit(500, 700);
}
document.add(tiff1);
document.newPage();
raf.close();
}




On Mon, Oct 26, 2009 at 11:03 AM, thulasi ram <pthulasi...@gmail.com> wrote:

> Paulo,
>
> Thanks for your code, its working for color images. I'm facing one issue, I
> have multipage tiff(morethan 3pages) , While doing the For loop 1st page is
> coming fine, Loop for 2nd page I'm getting "ExceptionConverter:
> java.io.EOFException" error.
>
> If anyone know the anser help me out with code.
>
> Here is my code.
> --------------------------
>
> String outputPdfFile = getTempPath()
> + ConstantsUtil.FOLDER_FILE_SEPERATOR + FName;
> String inputTiffFile = tempFile.getAbsolutePath();
> PdfWriter
> .getInstance(document, new FileOutputStream(outputPdfFile));
> document.open();
> // document.add(new Paragraph(
> // "This is the tiff added with Image.getInstance:"));
> Image tiff = Image.getInstance(inputTiffFile);  * // Reading the 1st page
> *if (tiff.getScaledWidth() > 500 || tiff.getScaledHeight() > 700) {
> tiff.scaleToFit(500, 700);
> }
> document.add(tiff);
> // document.add(Image.getInstance(inputTiffFile));
> RandomAccessFileOrArray ra = new RandomAccessFileOrArray(
> inputTiffFile);
> int pages = TiffImage.getNumberOfPages(ra);
> // document.add(new Paragraph(pages));
>
> *// Loop for other pages. Pages starts with 1.......*
> for (int i = 1; i < pages;) {
> ++i;
> document.newPage();
> *Image tiff1 = TiffImage.getTiffImage(ra, i);  // EOF error for 2time loop
> *
> if (tiff1.getScaledWidth() > 500
> || tiff1.getScaledHeight() > 700) {
> tiff1.scaleToFit(500, 700);
> }
> document.add(tiff1);
> }
> document.close();
> ra.close();
>
>
>
>
> On Thu, Oct 22, 2009 at 4:13 PM, Paulo Soares <psoa...@glintt.com> wrote:
>
>> Yes, it does support color images.
>>
>> Paulo
>>
>> ----- Original Message -----
>> From: "thulasi ram" <pthulasi...@gmail.com>
>> To: "Post all your questions about iText here"
>> <itext-questions@lists.sourceforge.net>
>> Sent: Thursday, October 22, 2009 9:27 PM
>> Subject: Re: [iText-questions] Help
>>
>>
>> Thanks Paulo. The method
>> TiffImage<
>> http://www.1t3xt.info/api/com/lowagie/text/pdf/codec/TiffImage.html
>> >.getTiffImage(ra,i)
>> not support for color images.
>>
>>
>> On Thu, Oct 22, 2009 at 5:13 AM, Paulo Soares
>> <psoa...@glintt.com<mailto:psoa...@glintt.com>> wrote:
>> It's always useful if someone does your work and I was already missing the
>> "send sample code". See http://1t3xt.be/?X0001bd.
>>
>> Paulo
>>
>> > -----Original Message-----
>> > From: thulasi ram
>> > [mailto:pthulasi...@gmail.com<mailto:pthulasi...@gmail.com>]
>> > Sent: Wednesday, October 21, 2009 11:42 PM
>> > To: Post all your questions about iText here
>> > Subject: Re: [iText-questions] Help
>> >
>> > Thanks, I'll try. Using getInstance(read); how can i loop the page.
>> > Can any one send me sample code its more useful for me.
>> >
>> > Thanks,
>> > Ram
>> >
>> >
>> >
>> > On Wed, Oct 21, 2009 at 5:39 PM, Paulo Soares
>> > <psoa...@glintt.com<mailto:psoa...@glintt.com>> wrote:
>> >
>> >
>> >       Use class com.lowagie.text.pdf.codec.TiffImage to get
>> > all the images inside the tiff.
>> >
>> >       Paulo
>> >
>> >
>> >       > -----Original Message-----
>> >       > From: thulasi ram
>>  > [mailto:pthulasi...@gmail.com<mailto:pthulasi...@gmail.com>]
>> >
>> >       > Sent: Wednesday, October 21, 2009 8:11 PM
>> >       > To: Post all your questions about iText here
>> >
>> >       > Subject: Re: [iText-questions] Help
>> >       >
>> >       > Thanks for ur response.
>> >       > I have one more issue.
>> >       > I have multipage color tiff, while i'm using
>> >       > Image.getInstance write to pdf file always getting single
>> >       > page pdf file.
>> >       >
>> >       > If i'll use Image.getInstance i can able to read color tiff
>> >       > images but i'm not able to create multipage pdf file.
>> >       > If I'll use Image.getTiffImage i can't able to read color
>> >       > tiff iamges.
>> >       >
>> >       > Can any one let me know how get multipage pdf file using
>> >       > Image.getInstance. Its posible to color Tiff to pdf
>> > file using iText?
>> >       >
>> >       > Here is my code.
>> >       > tempFile = new File(finalPath);
>> >       > FileOutputStream fileOutputStream = new
>> > FileOutputStream(tempFile);
>> >       > byte[] read = new byte[input.available()];
>> >       >
>> >       > File cacheFile = new File(finalPath1);
>> >       > FileOutputStream bos = new FileOutputStream(cacheFile);
>> >       >
>> >       > ByteArrayOutputStream outfile = new ByteArrayOutputStream();
>> >       > Document document = new Document(PageSize.A4.rotate());
>> >       > PdfWriter writer = PdfWriter.getInstance(document, bos);
>> >       > writer.setStrictImageSequence(true);
>> >       > document.open();
>> >       > Image tiff = Image.getInstance(read);
>> >       > tiff.scaleToFit(800, 600);
>> >       > document.add(tiff);
>> >       > document.close();
>> >       > outfile.flush();
>> >       >
>> >       >
>> >       >
>> >       >
>> >       >
>> >       >
>> >       > On Mon, Oct 19, 2009 at 3:39 PM, Paulo Soares
>> >       > <psoa...@glintt.com<mailto:psoa...@glintt.com>> wrote:
>> >       >
>> >       >
>> >       >       Not only that, if you use a stream it's read to a byte
>> >       > array. Use a file
>> >       >       instead.
>> >       >
>> >       >       Paulo
>> >       >
>> >       >
>> >       >       ----- Original Message -----
>> >       >       From: "Mark Storer"
>> > <msto...@autonomy.com<mailto:msto...@autonomy.com>>
>> >       >       To: "Post all your questions about iText here"
>> >       >
>> > <itext-questions@lists.sourceforge.net<mailto:
>> itext-questions@lists.sourceforge.net>>
>> >       >
>> >       >       Sent: Monday, October 19, 2009 9:24 PM
>> >       >       Subject: Re: [iText-questions] Help
>> >       >
>> >       >
>> >       >       Give the JVM more memory when you create it:
>> >       >
>> > http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html
>> >       >
>> >       >       This has almost nothing to do with iText, and
>> >       > everything to do with Java.
>> >       >
>> >       >
>> >       >       --Mark Storer
>> >       >        Senior Software Engineer
>> >       >        Cardiff.com
>> >       >
>> >       >       #include <disclaimer>
>> >       >       typedef std::Disclaimer<Cardiff> DisCard;
>> >       >
>> >       >       -----Original Message-----
>> >       >       From: thulasi ram
>> > [mailto:pthulasi...@gmail.com<mailto:pthulasi...@gmail.com>]
>> >       >       Sent: Monday, October 19, 2009 11:15 AM
>> >       >       To:
>> > itext-questions@lists.sourceforge.net<mailto:
>> itext-questions@lists.sourceforge.net>
>> >       >       Subject: [iText-questions] Help
>> >       >
>> >       >       Hi all,
>> >       >        I'm using iText Tiff2pdf method for converting Tiff to
>> >       > image pdf. I'm
>> >       >         getting "Outofmemory" error while converting large
>> >       > size (morethen 5MB)
>> >       >         images in the line of
>> >       >         ra = *new* RandomAccessFileOrArray(inStream);.
>> >       >         Can any one help how to create pdf for large
>> > size Tiff images.
>> >       >
>> >       >       Thanks,
>> >       >       Ram
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference
>> _______________________________________________
>> iText-questions mailing list
>> iText-questions@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> Buy the iText book: http://www.1t3xt.com/docs/book.php
>> Check the site with examples before you ask questions:
>> http://www.1t3xt.info/examples/
>> You can also search the keywords list:
>> http://1t3xt.info/tutorials/keywords/
>>
>
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to