【发布时间】:2020-07-12 17:12:33
【问题描述】:
我正在使用 domPDF 在用户提交按钮后生成 PDF。我注意到如果我使用
<link rel="stylesheet" href="{{asset('health/css/bootstrap.min.css')}}">
它不会生成 PDF,它总是永远加载。我尝试使用file_get_contents,但似乎它也不起作用。有人可以告诉我该怎么做吗?如果你知道。
控制器
$css = 'health/css/bootstrap.min.css';
$data_type = pathinfo($css, PATHINFO_EXTENSION);
$css_data = file_get_contents($css);
//I can get the image by using this code
$path = 'health/img/logo.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
//for testing view
return view('emails.form',compact('base64','css_data'));
刀片
<link rel="stylesheet" href="{{$css_data}}">
<img src="{{$base64}}" class="img img-fluid img-center">
【问题讨论】:
-
你找到解决办法了吗?
标签: php css laravel pdf pdf-generation