0 Replies Latest reply on Aug 18, 2008 2:26 PM by Alfredo Zermeño NÃÃ

    Problem to display PDF

    Alfredo Zermeño NÃà Newbie

      Hi,

      I'm trying to download a PDF that is generated on the fly by my webapp.
      When I use the h:commandButton tag to call the generator method, the PDF is displayed correctly, but when I use the a4j:commandButton tag, the PDF is interpreted as an image.

      The a4j's log write the next lines:

      [2008-08-18 13:21:01,958 http-8080-2] DEBUG org.ajax4jsf.webapp.BaseXMLFilter - create HTML/XML parser for content type: application/pdf
      [2008-08-18 13:21:01,958 http-8080-2] DEBUG org.ajax4jsf.webapp.BaseXMLFilter - Parser not have support for the such content type, send response as-is
      [2008-08-18 13:21:01,958 http-8080-2] DEBUG org.ajax4jsf.webapp.BaseFilter - Finished request processing total time 1000ms for uri: /CFD/jsp/pm/captur
      


      I'm setting up the PDF in this way:

      ByteArrayOutputStream stream = //method to generate the PDF
      FacesContext context = FacesContext.getCurrentInstance();
      HttpServletResponse response=(HttpServletResponse)context.getExternalContext().getResponse();
      response.setContentType("application/pdf");
      response.setHeader("Content-Disposition","attachment;filename=\"CFD.pdf\"");
      OutputStream out=response.getOutputStream();
      out.write(stream.toByteArray());
      out.flush();
      out.close();
      context.responseComplete();
      


      Please, help me to solve this problem. TY