我在wkhtmltopdf
项目中使用Snappy
和Laravel
生成pdf' s。但是,由于某种原因,我得到了不同的结果!
当我在Windows localhost环境中生成PDF时,我得到了正确的结果,我得到以下内容:
这是我期望的结果,所以在Windows上工作正常。但是,当我在运行Ubuntu的托管服务器上尝试此操作时,我得到以下结果:
代码
在我的控制器中:
$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或其他问题!希望有人可以提供帮助,以便两种结果看起来都一样。