1 Reply Latest reply on Dec 3, 2011 6:50 PM by pwillener

    Adobe Reader could not open 'xyz.pdf'

    Khatri Anand

      Hi,

       

      From my project I download pdf file. PDf file download in particular directory is successfully.

      But when I open that PDF then I got Error Message.

       

      "Adobe Reader could not open 'XYZ.pdf' because it is either not a supported file type or because the file has been damaged (for example. it was sent as an email attachment and wasn't correctly decoded). "

       

      so what's problem? how can fix this bug?

      My file download code

                          this.response.setHeader("Content-Disposition", "attachment;filename="+fileName+".pdf");

                                fileData = new byte[(int)file.length()];

                                in = new ByteArrayInputStream(fileData);

                              byte[] outputByte = new byte[4096];

                              //copy binary contect to output stream

                              while(in.read(outputByte, 0, 4096) != -1){

                                  outputStream.write(outputByte, 0, 4096);

                              }

                              in.close();

                              outputStream.flush();

                              outputStream.close();