You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Claus Weng Madsen - TELMORE <cw...@telmore.dk> on 2004/01/26 16:45:52 UTC
Struts & PDF
Hi
Does anyone know how to forward to pdf
I try something like this in my action
byte[] pdf = facade.getPdfBytesFor();
response.setContentType("application/pdf");
response.setContentLength(pdf.length);
response.getOutputStream().write(pdf);
response.getOutputStream().flush();
return null;
But it does'nt work :-(
Med venlig hilsen
Claus Weng Madsen, Teamleder
TELMORE A/S
Carl Gustavsgade 3, 2630 Taastrup
Telefon 70218700, Mobil 30242875
www.telmore.dk
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Struts & PDF
Posted by Franck Lefebure <fl...@orangecaraibe.com>.
Le Monday, January 26, 2004 11:45 AM,
Claus Weng Madsen - TELMORE <cw...@telmore.dk> m'a, d'une plume avisee, ecrit:
> Hi
>
> Does anyone know how to forward to pdf
>
reponse.reset();
reponse.setContentType("application/pdf");
reponse.setHeader("Content-Disposition", "attachment;
filename="+ fileName );
//reponse.setHeader("pragma","no cache");
out = reponse.getOutputStream();
FileReader fileRead = new FileReader(fileFacture);
in = new BufferedInputStream( new FileInputStream(
fileFacture ) );
BufferedReader buffFileln = new BufferedReader(fileRead);
byte[] buff = new byte[2048];
for(int count = 0; (count = in.read(buff)) != -1;) {
out.write(buff, 0, count);
}
Don't forget to close streams
Bye
--
Franck Lefebure
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org