Hi,

PDF file is a binary file!!!
Use this code it's work:

byte[] content = outPDF.toByteArray();
   response.setContentLength(content.length);
   response.getOutputStream().write(content);
   response.getOutputStream().flush();

D.Semprini


Carmelo Montanez wrote:
02be01c1452d$7953e270$[EMAIL PROTECTED]">
Hi All:
 
   I know that my browser can display PDF propertly now, however the following
piece of code (that generates PDF data) sends the data back to the client
(IE6) and still  does not not looks like PDF at all.  Can someone please tell me
if there is something wrong with this code.  By the way
(out = response.getOutputStream() and "foFile" comes from an "FO" file).
 
 
 
    public void renderFO(InputSource foFile, HttpServletResponse response)
     throws IOException
    {
      try {
        ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
        response.setContentType("application/pdf");
      
          Driver driver = new Driver(foFile, outPDF);
          driver.setRenderer(Driver.RENDER_PDF);
          driver.setOutputStream(outPDF);
          driver.run();
 
          byte[] content = outPDF.toByteArray();
          response.setContentLength(content.length);
          out.write(content);
          out.flush();
      }    
      catch (Exception ex) {
          System.out.println(ex);
      }
   
Thanks,
Carmelo Montanez
 
Carmelo Montanez
NIST Stop 8970
Gaithersburg, MD 20899
 
[EMAIL PROTECTED]

Reply via email to