首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wkhtmltopdf:更新了我的Ubuntu,得到了"QXcbConnection:未能连接到显示“

wkhtmltopdf:更新了我的Ubuntu,得到了"QXcbConnection:未能连接到显示“
EN

Stack Overflow用户
提问于 2016-05-08 13:37:42
回答 2查看 4.3K关注 0票数 2

有“phpwkhtmltopdf”的东西停止工作了。

在具有以下代码的web浏览器上运行:

代码语言:javascript
复制
    $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

我得到了这个输出:

代码语言:javascript
复制
QXcbConnection: Could not connect to display
Aborted (core dumped)

我唯一做的就是升级和升级。PHP5改为7,有什么问题吗?会不会有一个不小心被拿走的包裹?到现在为止一切都很顺利。

当我在CLI:xvfb-run wkhtmltopdf http://google.com test.pdf上运行时

这很管用..。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-05-11 11:21:12

发现问题了。有个CSS SRC错了..。

票数 -2
EN

Stack Overflow用户

发布于 2016-08-02 22:01:23

代码语言:javascript
复制
$binary = '/usr/bin/xvfb-run -- /usr/bin/wkhtmltopdf';
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37100442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档