My estimation is that that last line is accurate:  "java.lang.OutOfMemoryError".

The working image is 1704 pixels by 729 pixels.  I'm guessing that it's a black 
& white only file... 1 bit per pixel IN THE FILE.  The same goes for the image 
that fails, only it is 1706 by 2137... almost exactly three times taller.

I'm guessing that this "AXATiff2Pdf" library you're using converts the image 
data into 24-bit color in an intermediate stage.  The smaller image then 
becomes 1704 * 729 * 3 bytes = 3726648 bytes, just over 3.5mb.  The larger 
image now takes up 1706 * 2137 * 3 bytes = 10937116 bytes, a little under 
10.5mb.

If youre JVM doesn't have an extra 10.5mb of contiguous memory (all in one 
block) then it'll throw a java.lang.OutOfMemoryError.  To solve this, you have 
a couple options:

1) Write your own TIFF extractor (there are libraries out there to help) that 
never expands the image data out to 24-bit color.  10.5mb / 24 = 445kb.  That 
shouldn't be an issue.  PDF can accept B&W image data, and CCITT encoding will 
compress that further in the final file (CCITT is the B&W only compression 
scheme used in FAX machines).  This would take some work, but would be highly 
efficient, and other folks on the internet would be glad for such an 
enhancement to iText.

2) Allocate more memory for your JVM.  You can pass in an initial and maximum 
memory size as command line parameters when you launch your JVM (java.exe for 
example).  Quick, easy, inefficient.

The following example will start a JVM with 128 megabytes if initail memory, 
and will start throwing OutOfMemoryError exceptions when you try to exceed 
256mb (or ask for a chunk larger than the largest available block of memory).
java.exe -Xms128 -Xmx256

It's possible that the AXATiff2Pdf library isn't using a 24-bit intermidate 
stage, in which case I'd suspect that you have a very small JVM max memory 
setting.

--Mark Storer 
  Senior Software Engineer 
  Cardiff Software 
#include <disclaimer> 
typedef std::Disclaimer<Cardiff> DisCard; 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, August 23, 2006 8:31 AM
To: [email protected]
Subject: [iText-questions] (no subject)



Here is one tiff file that gives me an error when ourprogram tries to open the 
file  through ITEXT software. There is no problem in opening the file manually. 
But ITEXT somehow is complaining about the file. Here is code from ITEXT where 
it fails and the error from the log file. We are baffled how to tackle the 
problem. We get the file from the bank and they think that they send the 
right file. 

Any insight will be highly appreciated.  Why the program fails on this tiff 
file and not on others. I am sending you two tiff files, bad and good ones. 


Thanks 

sankar 


Here is one tiff file that gives me an error when ourprogram tries to open the 
file  through ITEXT software. There is no problem in opening the file manually. 
But ITEXT somehow is complaining about the file. Here is code from ITEXT where 
it fails and the error from the log file. We are baffled how to tackle the 
problem. We get the file from the bank and they think that they send the 
right file. 

Any insight will be highly appreciated.  Why the program fails on this tiff 
file and not on others. I am sending you two tiff files, bad and good ones. 


Thanks 

sankar 


 (good file) 

Extract from log file : 

Good 

com.axa.soc.AWDLockbox.AXATiff2Pdf: addOneTiffToDocument: begin 
com.axa.soc.AWDLockbox.AXATiff2Pdf: Processing: 
c:\AWDLockbox\zip\work/M285380F.tif 
com.axa.soc.AWDLockbox.AXATiff2Pdf: comps: 1 
com.axa.soc.AWDLockbox.AXATiff2Pdf: setFontAndSize1 
com.axa.soc.AWDLockbox.AXATiff2Pdf: Before running image: 
c:\AWDLockbox\zip\work/M285380F.tif 
com.axa.soc.AWDLockbox.AXATiff2Pdf: img [EMAIL PROTECTED] 
com.axa.soc.AWDLockbox.AXATiff2Pdf: page 1 
com.axa.soc.AWDLockbox.AXATiff2Pdf:  Debug: Rotated img 
c:\AWDLockbox\zip\work/M285380F.tif in pdf file 
c:\AWDLockbox\temp_rpts\Group_3_4_05_10_2006-00000015-0000013014-.pdf 
com.axa.soc.AWDLockbox.AXATiff2Pdf:  Debug: scaling img 
c:\AWDLockbox\zip\work/M285380F.tif in pdf file 
c:\AWDLockbox\temp_rpts\Group_3_4_05_10_2006-00000015-0000013014-.pdf 
com.axa.soc.AWDLockbox.AXATiff2Pdf:  Debug: about to close tiff file 
com.axa.soc.AWDLockbox.AXATiff2Pdf:  Debug: addOneTiffToDocument: end 
-------------------------------------------------------------------------------------------------------------------
 


(bad file) 

Errors 

com.axa.soc.AWDLockbox.AXATiff2Pdf: addOneTiffToDocument: begin 
com.axa.soc.AWDLockbox.AXATiff2Pdf: Processing: 
c:\AWDLockbox\zip\work/M285381F.tif 
com.axa.soc.AWDLockbox.AXATiff2Pdf: comps: 1 
com.axa.soc.AWDLockbox.AXATiff2Pdf: setFontAndSize1 
com.axa.soc.AWDLockbox.AXATiff2Pdf: Before running image: 
c:\AWDLockbox\zip\work/M285381F.tif 
com.axa.soc.AWDLockbox.AXALockboxProcessor:  Debug: Inside finally block of 
endprocess 
com.axa.soc.AWDLockbox.AXALockboxProcessor:  Debug: printStream not null 
java.lang.OutOfMemoryError 


Here is the code from ITEXT  where it fails: 

log.println("Processing: " + tiff_file); 
                try { 
                  for (int c = 0; c < comps; ++c) { 
                                          log.println("comps: " + comps); 
                      try { 
                          cb.beginText(); 
                            log.println ( "setFontAndSize1" ); 
                              cb.setFontAndSize(bf, 14); 
                              cb.setTextMatrix(30, 30); 
                              cb.showText( stampText ); 
                              cb.endText(); 
                              Image img = null; 
                          try{log.println("Before running image: " + 
tiff_file); 
                          img = TiffImage.getTiffImage(ra, c + 1); 
                                          } catch (Exception e) { 
                          log.logError("Exception " + tiff_file + " page " + (c 
+ 1) + " " + e.getMessage()); 
                          throw e; 
                                          } 
                          log.println("img " +img); 
                          if (img != null) 
                             {try 
                             { 
                              log.println("page " + (c + 1)); 
                              if ( img.scaledHeight() > img.scaledWidth() ) 
                              { 
                                img.setRotationDegrees( (long ) 90.0 ); 
                               log.debug ( "Rotated img " + tiff_file + " in 
pdf file " + pdf_file ); 
                              } 
                              if (true ) // (img.scaledWidth() > scale_width || 
img.scaledHeight() > scale_height) 
                              { 
                               log.debug ( "scaling img " + tiff_file + " in 
pdf file " + pdf_file ); 
                                img.scaleToFit(scale_width, scale_height); 
                              } 
                              if ( false ) // (center_image) // Temp resizing 
kludge. Don't center. 
                              { 
                                  double width_adjustment = (scale_width - 
img.scaledWidth())/ 2 ; 
                                  double height_adjustment = (scale_height - 
img.scaledHeight())/ 2 ; 
                                 log.debug ( tiff_file + " width_adjustment: " 
+ width_adjustment 
                                           + " height: " + height_adjustment ); 
                                  img.setAbsolutePosition(img_x + (int) 
width_adjustment, 
                                                          img_y + (int) 
height_adjustment); 
                              } 
                              else 
                              { 
                                  img.setAbsolutePosition(img_x, img_y); 
                              } 
                              cb.addImage(img); 
                              cb.beginText(); 
                              cb.setFontAndSize(bf, 14); 
                              cb.setTextMatrix(text_x, text_y); 
                              cb.showText( stampText ); 
                              cb.endText(); 
                              document.newPage(); 
                              ++pages; 
                                                  } 


"Paulo Soares" <[EMAIL PROTECTED]> 

08/02/2006 10:02 AM 
        
        To:        [EMAIL PROTECTED] 
        cc:         
        Subject:        Re: Tiff problem 




Works for me. I attach the generated PDF.

Paulo

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 02, 2006 1:02 PM
Subject: Tiff problem


> The following tiff file needs to be resized to 105% in Microsoft photo 
> editor before it can be processed through ITEXT program.
> 
> Thanks
> 
> sankar
> 
> 
> The following tiff file needs to be resized to 105% in Microsoft photo 
> editor before it can be processed through ITEXT program.
> 
> Thanks
> 
> sankar
> 
> 
> 
> 
> 
> 
> 
> 
>> -----Original Message-----
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On 
> > Behalf Of [EMAIL PROTECTED]
> > Sent: Wednesday, July 26, 2006 4:42 PM
> > To: [EMAIL PROTECTED]
> > Subject: [iText-questions] Tiff file problem
> > 
> > 
> > If the following statement fails due to corrupt image, how 
> > should we catch this error instead of  the program being 
> > abended and received an 'out of memory error ' 
> > 
> > Image img = TiffImage.getTiffImage(ra, c + 1); 
> >
> 
> You can't catch it, it must be solved before happening. If you have an
> image with that problem send it to me.
> 
> Paulo
> 




**********************************************************************

Confidentiality Note: This message and any attachments 
may contain legally privileged and/or confidential information. 
Any unauthorized disclosure, use or dissemination of this e-mail 
message or its contents, either in whole or in part, is prohibited. 
If you are not the intended recipient of this e-mail message, 
kindly notify the sender and then destroy it.

**********************************************************************

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to