1

the echo statement is not running and the below script is also not running

header("HTTP/1.1 200 OK");
                header("Pragma: public");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Cache-Control: private", false);
                header('Content-Type: application/pdf');
                header('Content-Disposition: attachment;filename="rename.pdf"'); //tell browser what's the file name
                header('Cache-Control: max-age=0'); //no cache
                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
                $objWriter->setSheetIndex($i);

                $objWriter->save('php://output');
               echo "this is not diplaying"; //code get terminated
kashif
  • 193
  • 2
  • 19

1 Answers1

0

Don't echo anything when you're sending data to php://output with file headers.... echo sends its data to php://output..... all you're doing is writing "this is not diplaying" at the bottom of the file that you're sending.... and the likelihood is that it will also corrupt that file

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • Yes..... don't ever echo anything else when you're outputting a file to the browser..... this isn't PHPExcel specific, it applies to any file generated or written to php://output by PHP.... you can only send one content type to a browser in response to one request – Mark Baker Nov 03 '15 at 07:59