
Christian Sciberras
By: a guest on Mar 19th, 2010 | syntax:
PHP | size: 0.60 KB | hits: 220 | expires: Never
function pipeExec($cmd,$input=''){
$proc=proc_open($cmd,array(0=>array('pipe','r'),1=>array('pipe','w'),2=>array('pipe','w')),$pipes);
fwrite($pipes[0],$input);
fclose($pipes[0]);
$stdout=stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr=stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn=proc_close($proc);
return array(
'stdout'=>$stdout,
'stderr'=>$stderr,
'return'=>$rtn
);
}
$cmd=KCS_APPLICATIONS::main()->path().'libraries/wkhtmltopdf/wkhtmltopdf-amd64'; // path to the static executable
$web='http://google.com/';
$pdf=self::pipeExec('"'.$cmd.'" "'.$web.'" -');