CakePdf\Pdf\Engine\WkHtmlToPdfEngine::_exec PHP Method

_exec() protected method

Execute the WkHtmlToPdf commands for rendering pdfs
protected _exec ( string $cmd, string $input ) : string
$cmd string the command to execute
$input string Html to pass to wkhtmltopdf
return string the result of running the command to generate the pdf
    protected function _exec($cmd, $input)
    {
        $result = ['stdout' => '', 'stderr' => '', 'return' => ''];
        $proc = proc_open($cmd, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
        fwrite($pipes[0], $input);
        fclose($pipes[0]);
        $result['stdout'] = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        $result['stderr'] = stream_get_contents($pipes[2]);
        fclose($pipes[2]);
        $result['return'] = proc_close($proc);
        return $result;
    }