Laravel wkhtmltopdf结果不同

时间:2017-03-14 10:51:46

标签: php laravel wkhtmltopdf snappy laravel-snappy

我在wkhtmltopdf项目中使用SnappyLaravel生成pdf' s。但是,由于某种原因,我得到了不同的结果!

当我在Windows localhost环境中生成PDF时,我得到了正确的结果,我得到以下内容:

enter image description here

这是我期望的结果,所以在Windows上工作正常。但是,当我在运行Ubuntu的托管服务器上尝试此操作时,我得到以下结果:

enter image description here

代码

在我的控制器中:

$view = view('pages.qr.sheet', [
    'qrs' => $qrs,
    'codes' => $codes,
    'checksums' => $checksums,
    'image' => public_path().'\\'.$sheet->image]);


return SnappyPdf::loadHTML($view)
    ->stream('my.pdf', array('Attachment'=>0));

我的Snappy配置文件:

'pdf' => array(
    'enabled' => true,
    'binary'  => "\"".base_path(env('SNAPPY_PATH', '/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'))."\"",
    'timeout' => false,
    'options' => array(
        'orientation' => 'landscape',
        'enable-javascript' => true,
        'javascript-delay' => 0,
        'no-stop-slow-scripts' => true,
        'no-background' => false,
        'lowquality' => false,
        'encoding' => 'utf-8',
        'images' => true,
        'cookie' => array(),
        'dpi' => 300,
        'image-dpi' => 300,
        'enable-external-links' => true,
        'enable-internal-links' => true
    ),
    'env'     => array(),
),

为什么结果差异如此之大? Windows版本看起来很完美,但是当我在托管网络服务器上运行它时,它并不适合一个页面。看起来这是DPI或其他问题!希望有人可以提供帮助,以便两种结果看起来都一样。

0 个答案:

没有答案