Return-Path: Delivered-To: apmail-myfaces-users-archive@www.apache.org Received: (qmail 75333 invoked from network); 5 Mar 2008 20:33:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Mar 2008 20:33:46 -0000 Received: (qmail 21559 invoked by uid 500); 5 Mar 2008 20:33:38 -0000 Delivered-To: apmail-myfaces-users-archive@myfaces.apache.org Received: (qmail 21523 invoked by uid 500); 5 Mar 2008 20:33:38 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 21512 invoked by uid 99); 5 Mar 2008 20:33:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2008 12:33:38 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gcjmu-myfaces-user@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2008 20:32:50 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JX0IW-0004TG-8Q for users@myfaces.apache.org; Wed, 05 Mar 2008 20:33:08 +0000 Received: from cpe0016b5ef7ea1-cm0014e88ef4b4.cpe.net.cable.rogers.com ([99.233.20.4]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Mar 2008 20:33:08 +0000 Received: from laurie by cpe0016b5ef7ea1-cm0014e88ef4b4.cpe.net.cable.rogers.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Mar 2008 20:33:08 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: users@myfaces.apache.org From: Laurie Harper Subject: Re: PDF+JSF question Date: Wed, 05 Mar 2008 15:32:58 -0500 Lines: 178 Message-ID: References: <2bd5ed640803040905j6dd01e09g7af3887de3d2fad2@mail.gmail.com> <2bd5ed640803041119i50c30bfdi58b29f807f89a1e0@mail.gmail.com> <1D3D7943573BD14FB024A9654EB43CCB01BF42A6@A99A-EMS-01VS2.ad.bedag.ch> <2bd5ed640803050702x425cd30ld422b6b309f4cb5f@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cpe0016b5ef7ea1-cm0014e88ef4b4.cpe.net.cable.rogers.com User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) In-Reply-To: <2bd5ed640803050702x425cd30ld422b6b309f4cb5f@mail.gmail.com> Sender: news X-Virus-Checked: Checked by ClamAV on apache.org That code creates a new PDF file from two existing byte arrays(?) on the = file system. The same code should work identically under JSF, the only=20 thing needing to be changed being context.getRealPath() -- is that the=20 bit you're asking for help with? You should be able to replace that with something like ((ServletContext) FacesContext.getCurrentInstance() .getExternalContext().getContext()).getRealPath(...) (assuming you're deploying your application to a Servlet container, not=20 a Portlet container). Does that help? L. daniel ccss wrote: > Thanks for the answer, but I think this is not what I need. >=20 > What i need is a way to join 2 or more reports in one pdf file, like is= done > in struts, with JSF: >=20 > *PdfReader reader1 =3D new PdfReader(bytes); > PdfReader reader2 =3D new PdfReader(bytes2); >=20 > PdfCopyFields copy =3D new PdfCopyFields(new FileOutputStream( > context.getRealPath("/reports/report1 " + name + ".pdf"))); >=20 > copy.addDocument(reader1); > copy.addDocument(reader2); > copy.close();* >=20 > Someone has the code to do this but in JSF?? Thanks!!! >=20 >=20 >=20 >=20 > On Wed, Mar 5, 2008 at 8:43 AM, Sertic Mirko, Bedag > wrote: >=20 >> Hi >> >> >> >> If you want to send a text as a download file to the browser, so somet= hing >> like this. You can also >> >> Send a binary file the same way by modifying this method a little bit = : >> >> >> >> *public* *void* sentFileToBrowser(FacesContext aContext, String >> aFileName, String aContent, *boolean* aAttachment) { >> >> >> >> *try* { >> >> HttpServletResponse theResponse =3D (HttpServletResponse) >> aContext.getExternalContext().getResponse(); >> >> theResponse.setCharacterEncoding("UTF-8"); >> >> >> >> MimeTypeGuesser theMimeTypeGuesser =3D MimeTypeGuesser.* >> getInstance*(); >> >> String theContentType =3D >> theMimeTypeGuesser.guessMimeTypeFromFileName(aFileName); >> >> >> >> *LOGGER*.logDebug("Content type is " + theContentType); >> >> >> >> String theContentDisposition =3D aAttachment ? "attachment= " : >> "inline"; >> >> >> >> theResponse.setContentType(theContentType); >> >> theResponse.setHeader("Content-disposition", >> theContentDisposition + "; filename=3D\"" + aFileName + "\""); >> >> >> >> // Make sure it is running with SSL smooth=85.. >> >> theResponse.setHeader("Pragma", "private"); >> >> >> >> PrintWriter theWriter =3D *new* PrintWriter(*new*OutputStr= eamWriter( >> theResponse.getOutputStream(), "UTF-8")); >> >> theWriter.print(aContent); >> >> theWriter.flush(); >> >> >> >> theWriter.close(); >> >> >> >> aContext.responseComplete(); >> >> >> >> } *catch* (Exception e) { >> >> *throw* *new* FacesException("Error sending file", e); >> >> } >> >> } >> >> >> >> Regards >> >> Mirko >> >> >> >> *Von:* daniel ccss [mailto:danielccss2@gmail.com] >> *Gesendet:* Dienstag, 4. M=E4rz 2008 20:20 >> *An:* users@myfaces.apache.org >> *Betreff:* Re: PDF+JSF question >> >> >> >> Anybody?? >> >> On Tue, Mar 4, 2008 at 11:05 AM, daniel ccss >> wrote: >> >> In Struts I do this for join 2 jasperreport pdfs: >> >> PdfReader reader1 =3D new PdfReader(bytes); >> PdfReader reader2 =3D new PdfReader(bytes2); >> >> PdfCopyFields copy =3D >> new PdfCopyFields(new FileOutputStream( context.getRealPath("/reportes= /Calificaci=F3n >> de Derechos por Beneficio >> Familiar - Resoluci=F3n N=BA " + >> beneficioForm.getNumeroResolucionBeneficio() + ".pdf"))); >> >> copy.addDocument(reader1); >> copy.addDocument(reader2); >> copy.close(); >> >> >> How can I do this en JSF?? >> >> Someone told me that use PdfCopyFields >> >> Have you tried passing the OutputStream from the response to the >> PdfCopyFields instead of a FileOutputStream? >> >> Can anyone give me an example of this? >> >> Thanks!! >> >> >> >=20