Php shell exec freezes when using wkhtmltopdf

I am trying to create a PDF from HTML using PHP. I use Mac OS X as a development environment, although I would like this code to run on a production Linux server.

So far I have received:

$url = escapeshellarg("http://www.google.com/"); $output = shell_exec("/usr/local/Cellar/wkhtmltopdf/0.11.0_rc1/bin/wkhtmltopdf " . $url . " /tmp/tmp_pdf.pdf 2>&1"); echo "<pre>$output</pre>"; 

This code creates a PDF file in the / tmp / tmp _pdf.pdf file. The problem is that he never does

 echo "<pre>$output</pre>"; 

The browser just hangs waiting for the server ....

Its almost as if the shell_exec command never ends. I notice that when wkhtmltopdf is launched from the terminal, it does not return to the command line. I get:

 Loading page (1/2) Printing pages (2/2) Done 

Then it sits too, like a php script. Any ideas?

+4
source share
1 answer

The problem was in the version used as rexmac . Using a static binary for wkhtmltopdf fixed the problem for the OP.

0
source

All Articles