domains/itbusinessnet.com.js
[app.webkitpdf] / webkitpdf.php
index e415472..4c470b5 100644 (file)
@@ -54,13 +54,15 @@ class WebkitPdf
         unlink($outpr);
         $out = $outpr .'.pdf';
         
-        $cmd = "timeout 30s $xvfb --auto-servernum $webkitpdf  " .
+        // can take 2-5 minutes... 
+        
+        $cmd = "timeout 300s $xvfb --auto-servernum $webkitpdf  " .
                 " --url " . escapeshellarg($_REQUEST['url']) . ' ' .
                 " --pdf " . $out . ' ';
                 
         $res = `$cmd`;
         
-        if (!file_exist($out)) {
+        if (!file_exists($out)) {
             $this->h404("Failed to create file $cmd  ==> $res");
         }
         
@@ -69,22 +71,14 @@ class WebkitPdf
         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("Last-Modified: " . gmdate("D, d M Y H:i:s",  time()) . " GMT");
 
-        header('Content-length: '. filesize($out));
-        header('Content-Disposition: '.$type.'; filename="' . htmlspecialchars($filename).  '"');
+        //header('Content-length: '. filesize($out));
+        header('Content-Disposition: attachment; filename="' . htmlspecialchars(basename($out)).  '"');
         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();
-        }
+        fpassthru($fh);
         
         fclose($fh);