wkhtmltopdf:更新了我的Ubuntu服务器并获得了;QXcbConnection:无法连接到显示器";
“phpwkhtmltopdf”的某些内容停止工作 使用以下代码在web浏览器上运行:wkhtmltopdf:更新了我的Ubuntu服务器并获得了;QXcbConnection:无法连接到显示器";,ubuntu,wkhtmltopdf,xvfb,phpwkhtmltopdf,Ubuntu,Wkhtmltopdf,Xvfb,Phpwkhtmltopdf,“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'
$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);
我把它装啊装啊装啊装啊装。。。我的putty windows开始运行非常慢,使处理器跳到100%。在我设法重新启动apache2或重新启动virtualbox之前,一切都会陷入困境
在CLI上运行:
wkhtmltopdfhttp://google.com google.pdf
我得到这个输出:
QXcbConnection: Could not connect to display
Aborted (core dumped)
我做的唯一一件事就是dist更新和升级。PHP5改为7。
有什么问题吗?是否存在意外删除的包?
到目前为止,它运作良好
在CLI上运行此命令时:
xvfb运行wkhtmltopdfhttp://google.com test.pdf
顺便说一句,它工作正常。发现了问题。
有一个CSS SRC是错误的 请在您的答案中添加更多信息,以便帮助其他有相同问题的人。
$binary = '/usr/bin/xvfb-run -- /usr/bin/wkhtmltopdf';