以前已经在某种程度上问过这个问题,但没有解决方案或可接受的答案,我想尝试更全面地回答我的问题,因此:
我正在尝试通过 PHP 在共享服务器上启动并运行 WKHTMLTOPDF(在本例中为 MediaTemple (gs))。根据主机的说法,这没有理由不起作用,事实上它是通过 SSH 工作的。所以...
我尝试了多种方法,最基本的方法什么也没做,只是默默地失败了:
exec("/path/to/binary/wkhtmltopdf http://www.google.com pdf1.pdf");
- Source: Question on Stack Overflow https://stackoverflow.com/questions/5630335/how-do-i-install-wkhtmltopdf-with-the-php-bindings-on-linux-centos
完整的 PHP 绑定以及以下错误给了我错误,尽管我用最好的谷歌搜索我还是无法弄清楚:
Call:
$html = file_get_contents("http://www.google.com");
$pdf = new WKPDF();
$pdf->set_html($html);
$pdf->render();
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');
- Source: WKHTMLTOPDF on Google Code http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp
Error:
Fatal error: Uncaught exception 'Exception' with message 'WKPDF didn't return
any data. <pre>Loading pages (1/6) [> ] 0% [======> ] 10% terminate called
after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc </pre>'
in /path/to/wkhtmltopdf.php:206 Stack trace: #0 /path/to/index.php(8):
WKPDF->render() #1 {main} thrown in /path/to/wkhtmltopdf.php on line 206
一旦我得到这个(下面是摘录,因为我现在无法重现它):
Qt Concurrent has caught an exception thrown from a worker thread. This is not
supported, exceptions thrown in worker threads must be caught before
control returns to Qt Concurrent.
我还尝试了其他一些选择,但结果相同;没有 PDF。那么我现在该怎么办,如何找出问题所在?我的PHP水平还处于初级阶段,但我会尽力而为。