Ric*_*hez 2 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'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);
Run Code Online (Sandbox Code Playgroud)
我得到它加载和加载和加载和加载...我的腻子窗口开始工作非常慢使处理器跳转到100%.在我设法service apache2 restart或重新启动virtualbox 之前,一切都会陷入困境.
在CLI上运行:
wkhtmltopdf http://google.com google.pdf
我得到这个输出:
QXcbConnection: Could not connect to display
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
我唯一做的就是改变和升级.PHP5改为7.可能是什么问题?可能有一个意外删除的包裹?直到现在它运作良好.
当我在CLI上运行时:
xvfb-run wkhtmltopdf http://google.com test.pdf
它工作顺便..
小智 5
$binary = '/usr/bin/xvfb-run -- /usr/bin/wkhtmltopdf';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4113 次 |
| 最近记录: |