Thanks for the answer, but I think this is not what I need.
What i need is a way to join 2 or more reports in one pdf file, like is done
in struts, with JSF:
*PdfReader reader1 = new PdfReader(bytes);
PdfReader reader2 = new PdfReader(bytes2);
PdfCopyFields copy = new PdfCopyFields(new FileOutputStream(
context.getRealPath("/reports/report1 " + name + ".pdf")));
copy.addDocument(reader1);
copy.addDocument(reader2);
copy.close();*
Someone has the code to do this but in JSF?? Thanks!!!
On Wed, Mar 5, 2008 at 8:43 AM, Sertic Mirko, Bedag <[EMAIL PROTECTED]>
wrote:
> Hi
>
>
>
> If you want to send a text as a download file to the browser, so something
> 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 = (HttpServletResponse)
> aContext.getExternalContext().getResponse();
>
> theResponse.setCharacterEncoding("UTF-8");
>
>
>
> MimeTypeGuesser theMimeTypeGuesser = MimeTypeGuesser.*
> getInstance*();
>
> String theContentType =
> theMimeTypeGuesser.guessMimeTypeFromFileName(aFileName);
>
>
>
> *LOGGER*.logDebug("Content type is " + theContentType);
>
>
>
> String theContentDisposition = aAttachment ? "attachment" :
> "inline";
>
>
>
> theResponse.setContentType(theContentType);
>
> theResponse.setHeader("Content-disposition",
> theContentDisposition + "; filename=\"" + aFileName + "\"");
>
>
>
> // Make sure it is running with SSL smooth…..
>
> theResponse.setHeader("Pragma", "private");
>
>
>
> PrintWriter theWriter = *new* PrintWriter(*new*OutputStreamWriter(
> 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:[EMAIL PROTECTED]
> *Gesendet:* Dienstag, 4. März 2008 20:20
> *An:* [email protected]
> *Betreff:* Re: PDF+JSF question
>
>
>
> Anybody??
>
> On Tue, Mar 4, 2008 at 11:05 AM, daniel ccss <[EMAIL PROTECTED]>
> wrote:
>
> In Struts I do this for join 2 jasperreport pdfs:
>
> PdfReader reader1 = new PdfReader(bytes);
> PdfReader reader2 = new PdfReader(bytes2);
>
> PdfCopyFields copy =
> new PdfCopyFields(new FileOutputStream(
> context.getRealPath("/reportes/Calificación
> de Derechos por Beneficio
> Familiar - Resolución Nº " +
> 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!!
>
>
>