webkitpdf.php
authorAlan Knowles <alan@roojs.com>
Mon, 23 Nov 2015 05:35:47 +0000 (13:35 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 23 Nov 2015 05:35:47 +0000 (13:35 +0800)
webkitpdf.php

index e2f0f2c..f56c6aa 100644 (file)
@@ -64,6 +64,33 @@ class WebkitPdf
             $this->h404("Failed to create file $cmd  ==> $res");
         }
         
+        header('Content-type: application/octet-stream');
+        
+        header("Expires: ");
+        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
+        header("Pragma: public");     
+        header("Last-Modified: " . gmdate("D, d M Y H:i:s",  $ts) . " GMT");
+
+        header('Content-length: '. filesize($out));
+        header('Content-Disposition: '.$type.'; filename="' . htmlspecialchars($filename).  '"');
+        ini_set('display_errors', 0);
+        
+        $fh = fopen($out, 'rb');
+        //fpassthru($fh);
+        
+        // passthrough seems to have problems -- trying fread
+        while(!feof($fh))
+        {
+            echo @fread($fh, 1024*8);
+            ob_flush();
+            flush();
+        }
+        
+        fclose($fh);
+    
+    
+        unlink($out);
+        exit;
         
         
     }