pdf显示无法连接服务器,wkhtmltopdf:更新了我的Ubuntu服务器,得到了“QXcbConnection:无法连接显示”...

'phpwkhtmltopdf'的某些内容已停止工作。

使用以下代码在网络浏览器上运行:

$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

它工作顺便..

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值