Thursday, February 21, 2008

pdf download on php

//$output = ob_get_flush(); //flushing the output
    ob_start(); //Turn on output buffering
    //This 5 lines codes are required to get pdf download in IE browser.
    header('Pragma: public');
    header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: pre-check=0, post-check=0, max-age=0');
    header('Content-Transfer-Encoding: none');
    header('Content-type: application/pdf');
    header("Content-Disposition: attachment; filename=$pdf_name");
    readfile($filename);
    ob_flush();  //Flush (send) the output buffer

No comments:

Post a Comment