You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Bjørn T Johansen <bt...@havleik.no> on 2005/02/28 13:06:01 UTC
Howto return a pdf file as a stream?
I was just wondering how do I return a PDF file as a stream as my response using
jsf/myfaces?
Regards,
BTJ
--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen
btj@havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------
Re: Howto return a pdf file as a stream?
Posted by Sean Schofield <se...@gmail.com>.
Yes that should work.
sean
On Mon, 28 Feb 2005 17:52:22 +0100, Bjørn T Johansen <bt...@havleik.no> wrote:
> So I can just copy my method from an Struts application I have and apply it here,
> just instead of returning null I just call context.responseComplete(); at the end?
>
>
> BTJ
>
> Sean Schofield wrote:
> >> context.responseComplete();
> >
> >
> > This line is the key.
> >
> > Make sure you are able to return a PDF as a servlet or something first
> > just to make sure you have everything figured out (assuming you are
> > new to writing PDF.) Then try with faces.
> >
> >
> >>Rico
> >
> >
> > sean
>
>
Re: Howto return a pdf file as a stream?
Posted by Bjørn T Johansen <bt...@havleik.no>.
So I can just copy my method from an Struts application I have and apply it here,
just instead of returning null I just call context.responseComplete(); at the end?
BTJ
Sean Schofield wrote:
>> context.responseComplete();
>
>
> This line is the key.
>
> Make sure you are able to return a PDF as a servlet or something first
> just to make sure you have everything figured out (assuming you are
> new to writing PDF.) Then try with faces.
>
>
>>Rico
>
>
> sean
Re: Howto return a pdf file as a stream?
Posted by Sean Schofield <se...@gmail.com>.
> context.responseComplete();
This line is the key.
Make sure you are able to return a PDF as a servlet or something first
just to make sure you have everything figured out (assuming you are
new to writing PDF.) Then try with faces.
> Rico
sean
Re: Howto return a pdf file as a stream?
Posted by Rico Wiese <Ri...@data-experts.de>.
Hi Bjorn,
here is just the way how we did it:
public void print(ActionEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response =
(HttpServletResponse) context.getExternalContext().getResponse();
response.setContentType("application/pdf");
FpRegisterableEJB bean = null;
try {
bean = createEquipedBean( getLink() );
JCPrinter printer = PrintManager.getPDFPrinter(
response.getOutputStream() );
PrintManager.printDocument( getReport( printer , bean ) , printer );
} catch (Exception e) {
logAndRethrowException( e );
} finally{
removeBean(bean);
}
context.responseComplete();
}
regards
Rico
Bjørn T Johansen <bt...@havleik.no> schrieb am 28.02.2005 13:06:01:
> I was just wondering how do I return a PDF file as a stream as my
> response using
> jsf/myfaces?
>
>
> Regards,
>
> BTJ
>
> --
>
-----------------------------------------------------------------------------------------------
> Bjørn T Johansen
>
> btj@havleik.no
>
-----------------------------------------------------------------------------------------------
> Someone wrote:
> "I understand that if you play a Windows CD backwards you hear
> strange Satanic messages"
> To which someone replied:
> "It's even worse than that; play it forwards and it installs Windows"
>
-----------------------------------------------------------------------------------------------
>