On 23/12/2011 16:58, Siddhartha Rathi wrote:
> Thanks 1T3XT BVBA,
>
> Can you help me in how to write the file in memory and send it to user
> directly? As I am not very comfortable with Java coding.

That's not an iText question; it's a general Java question.

I'll answer it this one time, but please post question about Java on a 
Java forum.

Right now you're using a FileOutputStream. This writes a PDF file to the 
file system.
If you use a ByteArrayOutputStream, you can write a PDF file to a byte 
array in memory.
When you've finished writing the file (after document.close()), you can 
retrieve the bytes using the toByteArray() method.
This byte[] can then be written to the response output stream.

There are many possible shortcuts.
For instance: you could write the bytes straight to the ServletOutputStream.
However: there are some pitfalls (explained in chapter 9 of the iText in 
Action book) with this approach.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
iText-questions mailing list
[email 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

Reply via email to