带有“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)
我唯一做的就是 dist-update 和升级。PHP5 改为 7. 可能是什么问题?可能有一个包被意外删除了?到现在为止它工作得很好。
当我在 CLI 上运行它时:
xvfb-run wkhtmltopdf http://google.com test.pdf
顺便说一句,它有效。