So much code and nothing useful to see. If your problem is with
ByteArrayOutputStream why don't you post the code that uses it?

Paulo

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of marlonbrando
> Sent: Monday, March 17, 2008 5:04 PM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] tiff2pdf byte Array problem
> 
> 
> hello to all....i have write a little application that 
> convert a multipage
> tiff to a multipage pdf...
> 
>         OutputStream fout =new FileOutputStream("result.pdf");
>         Document document = new Document();
>         PdfWriter writer = PdfWriter.getInstance(document,fout);
>         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;
>                                           }
>                                               cb.getPdfDocument();
>                                       } catch (Throwable e) {
>                                               e.printStackTrace();
>                                       }
>                               }
>       
>                       } catch (Throwable e) {
>                               e.printStackTrace();
>                       }
>                              document.close();
> }
> 
> this code work fine.
> 
> but if i set      PdfWriter writer = 
> PdfWriter.getInstance(document,new
> ByteArrayOutputStream);
> 
> and then i write the content of outputstream on a file the 
> pdf result is
> corrupted...
> Can anyone help me??????


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
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/

Reply via email to