Java Mailing List Archive

Home » Post all your questions about iText here »

[iText-questions] Application stopped without any error <Pls Help>

Joed Cueto


Author LoginPost Reply

I have an application that convert an inputSteam to pdf. Below is the content of the method that converts input stream to pdf. However, the application suddenly stopped on line "RandomAccessFileOrArray ra = new RandomAccessFileOrArray(inputStream);" without throwing any error or exception which is kind of weird. Is it a known bug, can you give some solution for this?? Thank you.. Badly needed. Please help 

Code Content >>>>

ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();

Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, baosPDF);"");;

RandomAccessFileOrArray ra = new RandomAccessFileOrArray(inputStream);
int pages = TiffImage.getNumberOfPages(ra);
for(int i = 1; i <= pages; i++){
Image img = TiffImage.getTiffImage(ra, i);
if((img.getScaledWidth() > 525) || (img.getScaledHeight() > 800)) 
img.scaleToFit(525, 800);
catch (DocumentException de) 
throw de;
catch (IOException ioe) 
throw ioe;
catch (Exception ex){
throw ex;

return baosPDF;

This is how I generate the inputstream

ByteArrayOutputStream baosPDF = null;
log.debug("start merge tiff.");
File tempFile = null;
if (iioimageList != null && iioimageList.size() > 0) 
Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("tiff");
ImageWriter writer =;

tempFile = File.createTempFile("test", ".tif");
ImageOutputStream ios = ImageIO.createImageOutputStream(tempFile);
IIOImage firstIioImage = iioimageList.remove(0);
int i = 1;
for (IIOImage iioImage : iioimageList) 
writer.writeInsert(i++, iioImage, null);
InputStream inputStreamNew = null;"create new file input stream from file.");
inputStreamNew = new FileInputStream(tempFile);


Joed G. Cueto
Software Engineer, Java Practice 
Business: +632 814 1100 
Pointwest Technologies Corporation
Pointwest Logo
12/F Citibank Center, 8741 Paseo de Roxas, Makati City, PH 1226

CONFIDENTIALITY NOTICE: This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited. If you have received this communication in error, please notify the sender immediately by e-mail and delete the message and any file attachments from your computer. There is no warranty that this email is error, virus or defect free. If this is a private communication it does not represent the views of Pointwest Technologies Corporation or their related entities.

This email is sponsored by Windows:

Build for Windows Store.
iText-questions mailing list

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book:
Please check the keywords list before you ask for examples:
©2008 - Jax Systems, LLC, U.S.A.