Answer the question
In order to leave comments, you need to log in
Why does wkhtmltopdf generate curve pdf via proc_open?
Good afternoon, I'm testing wkhtmltopdf on Win via openserver.
Pdf is correctly formed if I execute:
exec("C:\wkhtmltopdf\bin\wkhtmltopdf.exe -q http://example.com/ my.pdf");
$html = file_get_contents("http://example.com/");
$descriptorspec = array(
0 => array("pipe", "r"), // stdin это канал, из которого потомок будет читать
1 => array("pipe", "w"), // stdout это канал, в который потомок будет записывать
2 => array("pipe", "w"), // stderr это файл для записи
);
$process = proc_open("C:\wkhtmltopdf\bin\wkhtmltopdf.exe -q - -", $descriptorspec, $pipes, null, null, ['bypass_shell' => true]);
if (is_resource($process)) {
fwrite($pipes[0], $html);
fclose($pipes[0]);
$pdf = stream_get_contents($pipes[1]);
$errors = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($process);
if ($errors) {
echo 'PDF generation failed: ' . $errors;
} else {
header('Content-Type: application/pdf');
header('Content-Length: ' . strlen($pdf));
echo $pdf;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question