Java Mailing List Archive

http://www.junlu.com/

Home » Post all your questions about iText here »

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

Joed Cueto

2013-06-24


Author LoginPost Reply
Hi,

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

try 
{
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, baosPDF);
log.info("Document.open");
document.open();

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);
}
document.add(img);
}
document.close();
catch (DocumentException de) 
{
log.error(de.getMessage());
throw de;
catch (IOException ioe) 
{
log.error(ioe.getMessage());
throw ioe;
}
catch (Exception ex){
log.error(ex.getMessage());
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 = writers.next();

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

--

Joed G. Cueto
Software Engineer, Java Practice 
Business: +632 814 1100 
Email: joed.cueto@pointwest.com.ph
Website: www.pointwest.com.ph
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 SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions

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: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
©2008 junlu.com - Jax Systems, LLC, U.S.A.