dompdf 不使用 barryvdh/laravel-dompdf 加载 bootstrap css
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48760296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dompdf dont load bootstrap css with barryvdh/laravel-dompdf
提问by jhoss
i use barryvdh/laravel-dompdf in laravel 5.5 and bootstrap css (renamed to pdf.css with small adjustments) to generate a report in pdf this is my header from the report view calling the css:
我在 laravel 5.5 中使用 barryvdh/laravel-dompdf 和 bootstrap css(通过小的调整重命名为 pdf.css)以生成 pdf 报告,这是我从报告视图调用 css 的标题:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="{{public_path('css/pdf.css') }}" rel="stylesheet" type="text/css" />
</head>
<body>
my controller:
我的控制器:
public function infor(News $news)
{
...
PDF::setOptions(['dpi' => 150, 'defaultFont' => 'sans-serif']);
$pdf = PDF::loadView('admin.news_events.pdf');
return $pdf->stream('pdfview.pdf');
}
回答by Sapnesh Naik
barryvdh/laravel-dompdfdoes not support boostrap yet.
barryvdh/laravel-dompdf 尚不支持 boostrap。
Quoting the author:
引用作者:
I highly doubt that DomPDF can handle Bootstrap correctly. If you need better pdf, try: https://github.com/barryvdh/laravel-snappyThat used Webkit to render pdf.
我非常怀疑 DomPDF 能否正确处理 Bootstrap。如果您需要更好的 pdf,请尝试:https: //github.com/barryvdh/laravel-snappy使用 Webkit 渲染 pdf。
See more about the issue here
在此处查看有关此问题的更多信息
回答by Salem loress
You have to put all css file in style tag to launch your code
您必须将所有 css 文件放在 style 标签中才能启动您的代码