Ok, ByteArrayOutputStream baos =new ByteArrayOutputStream(); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document,baos); try { int pages = 0; document.open(); PdfContentByte cb = writer.getDirectContent(); RandomAccessFileOrArray ra = null; int comps = 0; try { ra = new RandomAccessFileOrArray(tiff.getStream()); comps = TiffImage.getNumberOfPages(ra); for (int c = 0; c < comps; ++c) { try { Image img = TiffImage.getTiffImage(ra,c+1); long h = 0; long w = 0; if (img != null) { Float height = new Float(img.getScaledHeight()); h = height.longValue(); Float width = new Float(img.getScaledWidth()); w = width.longValue(); float percent = 100; int pos = 0; if (w > 895) percent = ((595 + 18) * 100 / w); if (h > 842) pos = (int) (842 - h * percent / 100); else pos = (int) (842 - h); img.scalePercent(percent); img.setAbsolutePosition(0,pos); document.add(new Paragraph()); cb.addImage(img); document.newPage(); ++pages; } } catch (Throwable e) { e.printStackTrace(); } } } catch (Throwable e) { e.printStackTrace(); } FileOutputStream fos= new FileOutputStream("result.pdf"); fos.write(baos.toByteArraY()); document.close(); } the code for conversion is the same. I must use a byte array because i want to return this to another method.
Fabrizio Accatino wrote: > > Post the source code where you use ByteArrayOutputStream. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ > > -- View this message in context: http://www.nabble.com/tiff2pdf--byte-Array-problem-tp16097034p16105705.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/