Oh, what a world of pain.
IE in this regard is a pile of *@!# and NS is the absolute honey  :)

This is off-struts, but I know the pain you go through to get IE going 
properly.

Here's what I had to do to get it running reliably...


// START CODE --==>>

// set the response type
response.setContentType("application/pdf");
// set the content details
response.setHeader("Content-Disposition", "inline; 
filename=ConfirmationLetter.pdf; ");

// creating a temporary output stream
ByteArrayOutputStream bout = new ByteArrayOutputStream();

// this class takes teh xml document and runs it through the FOP process
// and pumps it into the output stream created.
OnlineSalesPDFGenerator pdf = new OnlineSalesPDFGenerator(xmlDoc);
pdf.run(form,request,bout);

byte[] content = bout.toByteArray();

// set the exact content length from our temp output stream
response.setContentLength(content.length);

// write the content
response.getOutputStream().write(content);

// flush the stream
response.getOutputStream().flush();

// <<==-- END CODE


I went through a lot of pain to get all the alternatives people were 
doing to get this. Important parts are...
a) The response type.
b) The Content-Disposition details. This sets filenames and stuff for 
the file saving dialog boxes etc.
c) Setting the exact content length. Made possible by writing to the 
ByteArrayOutputStream and getting its resulting size.

And if you're pessimistic (most likely you are by now :), make sure you 
flush and close the output stream, and you can also throw in what Gregor 
says below with your URL. After the above though, you shouldn't have any 
problems.

Hopefully this will get you where you need to be.


Arron.


Gregor Rayman wrote:

>"John Ng" <[EMAIL PROTECTED]> wrote:
>
>>Hi, The following is a piece of the code that I write
>>in the perform method of an ActionForm to generate the
>>PDF.  However, it works fine in netscape, but NOT IE. 
>>Can someone help me with this?
>>
>>Thanks!
>>John 
>>
>
>Try adding "?.pdf" to the url.
>
>--
>gR
>
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>



Reply via email to