code: protected void render(Source src, Transformer transformer, HttpServletResponse response)
                  throws FOPException, TransformerException, IOException {
  
          FOUserAgent foUserAgent = getFOUserAgent();
  
          //Setup output, assume 1 kb to avoid at least some copy-up
          ReadableByteArrayOutputStream out =
                  new ReadableByteArrayOutputStream(1024);
  
          //Setup FOP
          Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
  
          //Make sure the XSL transformation's result is piped through to FOP
          Result res = new SAXResult(fop.getDefaultHandler());
  
          //Start the transformation and rendering process
          transformer.transform(src, res);
  
          //Return the result
          response.setContentType("application/pdf");
          response.setContentLength(out.length());
          out.writeAllTo(response.getOutputStream());
          response.getOutputStream().flush();
      }
docs: Renders an input file (XML or XSL-FO) into a PDF file. It uses the JAXP
  transformer given to optionally transform the input document to XSL-FO.
  The transformer may be an identity transformer in which case the input
  must already be XSL-FO. The PDF is written to a byte array that is
  returned as the method's result.
  @param src Input XML or XSL-FO
  @param transformer Transformer to use for optional transformation
  @param response HTTP response object
  @throws FOPException If an error occurs during the rendering of the
  XSL-FO
  @throws TransformerException If an error occurs during XSL
  transformation
  @throws IOException In case of an I/O problem