Looking through your documentation it states:
When I test producing a raster image using PHP and piping the input and output, the $stdout is always empty.
However when I define the output path the image is saved to the file system as expected.
I've also tried the following command combinations which did not work either.
Any help in being able to pipe the raster result would be much appreciated.
I'm using Prince Version 11-1 on Ubuntu 16.04
Prince also accepts `-' meaning the standard output stream.
When I test producing a raster image using PHP and piping the input and output, the $stdout is always empty.
function convertHtmlToPng($html)
{
$command = 'prince --raster-dpi=300 --raster-pages=first --raster-output=-';
$descriptors = array(
array('pipe', 'r'),
array('pipe', 'w'),
array('pipe', 'w'),
);
$process = proc_open($command, $descriptors, $pipes, null, null);
if (!is_resource($process))
{
throw new Exception('Failed to execute command and open file pointers.');
}
fwrite($pipes[0], $html);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$result = proc_close($process);
return $stdout;
}
However when I define the output path the image is saved to the file system as expected.
$command = 'prince --raster-dpi=300 --raster-pages=first --raster-output=/home/user/test.png';
I've also tried the following command combinations which did not work either.
$command = 'prince --raster-dpi=300 --raster-pages=first --raster-output -';
$command = 'prince --raster-dpi=300 --raster-pages=first --raster-output=test.png --raster-output -';
Any help in being able to pipe the raster result would be much appreciated.
I'm using Prince Version 11-1 on Ubuntu 16.04