I use wkhtmltopdfto convert HTML documents to PDF files on our website. I use the following code in my PHP class:
<?php
$pdfConv = proc_open('wkhtmltopdf -q -s letter --no-background --print-media-type --title Test - -', [
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w')
], $pipes, '/tmp', NULL, [
'bypass_shell' => true
]);
if(is_resource($pdfConv)){
fwrite($pipes[0], $htmlData);
fclose($pipes[0]);
$pdfFile = stream_get_contents($pipes[1]);
fclose($pipes[1]);
proc_close($pdfConv);
}
NOTE. For testing purposes, I did $htmlData = file_get_contents('http://google.com');.
When I looked at the page in my web browser and clicked "download PDF", I got the following output:

( Download Source PDF )
Trying to understand what was wrong, I took on the command line and ran:
wkhtmltopdf -q -s letter --no-background --print-media-type --title Test http://google.com /tmp/google.pdf
This worked fine, so I thought something was wrong with PHP. I typed php -aand pasted the above code into the command line and ran it, and it worked perfectly.
Here's what the PDF looks like:

( Download Source PDF )
Apache ( -) PDF , ? ? ?