Hi,
You could make the pdf file as downloadable instead of trying to open the
pdf inside web browser ,Following code will make the pdf download
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
document.add(new Phrase("Some dummy text goes here",font));
document.close();
// setting some response headers
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate, post-check=0,
pre-check=0");
response.setHeader("Pragma", "public");
// setting the content type
response.setContentType("application/pdf");
response.addHeader("Content-disposition",
"attachment;filename=\"GCQuotes.pdf\"");
// the contentlength is needed for MSIE!!!
response.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream outs = response.getOutputStream();
outs.write(baos.toByteArray()) ;
outs.flush() ;
outs.close() ;
The above examples uses a third party PDF wrtier API 'itext'
----- Original Message -----
From: "Rivka Shisman" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Monday, January 02, 2006 11:24 AM
Subject: RE: closing the browser after streaming a pdf file
Hi Tamas and thanks for trying,
What I want to do is to create a pdf report in memory and stream it from
my Action to Acrobat.
The problem is that first I.E. opens and then Acrobat is opened. But now
I have an empty I.E window that I want to close (don't want the user to
do it each time).
Thanks
Rivka
-----Original Message-----
From: Tamas Szabo [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 29, 2005 6:10 PM
To: Struts Users Mailing List
Subject: Re: closing the browser after streaming a pdf file
Hi
On 12/29/05, Rivka Shisman <[EMAIL PROTECTED]> wrote:
Hi Tamas
In my jsp I do:
<html:form action="/CreateMsvItemReports" target="_new"
focus="item_no">
I want to save the original jsp page - that's why I use target="_new".
When I remove the ' target="_new" ' I still get an empty jsp page - so
still it does not solve my original problem!
I don't know what do you wnat to do exactly.
But you probably get that empty browser because the Acrobat Reader
plugin is
set up so that it opens in a new window instead of opening in a browser.
You can change this option in the Preferences of Acrobat Reader.
Does this solve your problem?
The only problem is that if it's an Internet application(usable by
anyone)
you can't control how the users will configure their Acrobat Reader
plugins.
Thanks
Rivka
Tamas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.10/218 - Release Date: 1/2/2006
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]