有“phpwkhtmltopdf”的东西停止工作了。
在具有以下代码的web浏览器上运行:
$string = "http://www.google.com";
// You can add parameter for the constructor call
$binary = '/usr/bin/wkhtmltopdf';
$pdf = new Pdf(array(
// Explicitly tell wkhtmltopdf that we're using an X environment
// 'use-xserver',
// Enable built in Xvfb support in the command
'commandOptions' => array(
'enableXvfb' => true,
// Optional: Set your path to xvfb-run. Default is just 'xvfb-run'.
'xvfbRunBinary' => '/usr/bin/xvfb-run',
// Optional: Set options for xfvb-run. The following defaults are used.
//'xvfbRunOptions' => '--server-args="-screen 0, 1024x768x24"',
),
));
$options = array(
// 'page-width' => '216mm',
// 'page-height' => '279mm',
'page-size' => 'A4',
//'dpi' => 96,
//'image-quality' => 100,
//'disable-smart-shrinking',
//'no-outline',
//'no-outline', // option without argument
'encoding' => 'UTF-8', // option with argument
'user-style-sheet' => $cssPath,
'margin-top' => 0,
'margin-right' => 0,
'margin-bottom' => 0,
'margin-left' => 0
// 'orientation' => 'portrait',
// 'images' => true,
// 'cookie' => array(),
//'dpi' => 1000
// 'image-dpi' => 300
// Default page options
// 'enable-smart-shrinking'
);
//$pdf->setOptions( $options );
$pdf->binary = $binary;
$pdf->addPage($string);
$pdf->saveAs(FCPATH."files/weekly_reports/$prod_id-Weekly-Report.pdf");
var_dump($pdf);我得到了装载和装载..。我的油灰窗口开始工作非常慢,使处理器跳转到100%。在我设法service apache2 restart或重新启动virtualbox之前,一切都会陷入僵局。
在CLI上运行:wkhtmltopdf http://google.com google.pdf
我得到了这个输出:
QXcbConnection: Could not connect to display
Aborted (core dumped)我唯一做的就是升级和升级。PHP5改为7,有什么问题吗?会不会有一个不小心被拿走的包裹?到现在为止一切都很顺利。
当我在CLI:xvfb-run wkhtmltopdf http://google.com test.pdf上运行时
这很管用..。
发布于 2016-05-11 11:21:12
发现问题了。有个CSS SRC错了..。
发布于 2016-08-02 22:01:23
$binary = '/usr/bin/xvfb-run -- /usr/bin/wkhtmltopdf';https://stackoverflow.com/questions/37100442
复制相似问题