Thanks Iliadis.

Can you tell me the point where the Baos actually gets populated?

I'm not sure what point in the R&J code acutally runs iText. It's not clearly commented where this happens.

I have all the Servlet code working and ready to go so that part is OK.

I've modifed the R&J code somewhat (though the inner classes are still there).

My createNewDocument() is unchanged from the example.

public void createNewDocument()
  {
     document = new Document(PageSize.A4, 80, 50, 30, 65);
  }

In step 2, I have:

writer = PdfWriter.getInstance(document,  baos);

From your reply below, it sounds like you're returning the baos after step 4
as commented in the code. However, although I've been populating things like your email, my baos is empty after the
parser.parse(...) code in step 4.

I'm assuming you're using the tagmap files and such too.

Thanks in advance.

- M

From: "Iliadis Yannis" <[EMAIL PROTECTED]>
Reply-To: Post all your questions about iText here <[email protected]> To: "Post all your questions about iText here" <[email protected]>
Subject: Re: [iText-questions] BAOS in one step?
Date: Mon, 21 May 2007 14:37:33 +0300

I did the following and it worked for me.

I created a test class which has a main method (just for testing purpose):

   public static void main(String[] args) {
       ByteArrayOutputStream bs;
       RomeoJulietBaos rmBaos=new RomeoJulietBaos();

       bs=rmBaos.mainExecute();
       System.out.println(bs);

   }

My second step was to alter the RomeoJuliet.java code like this:

I changed the main method to mainExecute with ByteArrayOutputStream as
return type:

public ByteArrayOutputStream mainExecute() {

inside I added the following:

       ByteArrayOutputStream baos=new ByteArrayOutputStream();
       try {
           // step 2:
           // we create a writer that listens to the document
           // and directs a XML-stream to a file
           PdfWriter writer = PdfWriter.getInstance(document,baos);

Instead of a FileOutPutStream, I pass the baos as parameter to the
PdfWriter.

The last step was to return the baos to the caller class:

       document.close();
       return bs;
   }

This worked fine and the result was printed to the console.

As I recall your original post, you mentioned that you want to display the
output in a browser. So you only need to change my test class to a servlet
with the proper response commands (see the link I send you last time), to
open the pdf.

_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best Web mail—award-winning Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to