之前已经在某种程度上提出过这个问题,但没有解决方案或可接受的答案,我想尝试在我的问题中更全面,所以:
我正在尝试在共享服务器上通过 PHP 启动并运行 WKHTMLTOPDF(在本例中为 MediaTemple (gs))。根据主机的说法,这没有理由不起作用,实际上它是通过 SSH 工作的。所以...
我尝试了各种各样的东西,最基本的什么都不做,只是默默地失败了:
exec("/path/to/binary/wkhtmltopdf http://www.google.com pdf1.pdf");
完整的 PHP 绑定以及以下内容给了我错误,尽管我用最好的谷歌搜索我无法弄清楚:
称呼:
$html = file_get_contents("http://www.google.com");
$pdf = new WKPDF();
$pdf->set_html($html);
$pdf->render();
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');
错误:
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 水平处于基本水平,但我会尽力而为。