I'm really interested in using iText with JSF. I've seeing the article wrotten at: http://www.opensubscriber.com/message/itext-questions@lists.sourceforge.net/4694363.html
and the other at: http://forum.java.sun.com/thread.jspa?threadID=703175&messageID=4213567 and I tried to generate a program using iText with JSF but I've got an IOException at the document.close(). The code I'm using is the following: Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { PdfWriter.getInstance(document, baos); document.open(); String msg = "Esto va a ser una buena prueba"; document.add(new Paragraph("hola mundo")); document.add(new Paragraph(new Date().toString())); } catch (DocumentException ex) { addErrorMessage("Error en generación de documento para imprimir"); } document.close(); FacesContext context = FacesContext.getCurrentInstance(); Object response = context.getExternalContext().getResponse(); if (response instanceof HttpServletResponse) { HttpServletResponse hsr = (HttpServletResponse)response; hsr.setContentType("application/pdf"); hsr.setHeader("Content-disposition", "attachment"); hsr.setContentLength(baos.size()); try { ServletOutputStream out = hsr.getOutputStream(); baos.writeTo(out); out.flush(); } catch (IOException ex) { addErrorMessage("Error en generación de documento para imprimir"); } //Tell JSF to skip the remaining phases of the lifecycle context.responseComplete(); } ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/