Reputation: 487
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:
<!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');
}
view generated in pdf :,( How could I solve this?
Upvotes: 8
Views: 40984
Reputation: 31
Try to set isHtml5ParserEnabled
option to true
:
PDF::setOptions(['dpi' => 150, 'isHtml5ParserEnabled' => true, 'defaultFont' => 'sans-serif']);
This will enable HTML5 parser (disabled by default in the package).
Upvotes: 0
Reputation: 1448
I had the same issue, all I did was create another blade file, copied bootstrap.css contents into it (between style tags) , then included it (the file with the css) in the file I wanted to print
Upvotes: 1
Reputation: 29
You should use another version of bootstrap. because i tested it with bootstrap 3 and it's not working but it works with version 4 of the framework.
Upvotes: 0
Reputation: 55
Change your file path to this, if CSS and images are not inside the public directory.
<img src="{{ base_path().'/location/to/image/image.png' }}" />
<link rel="stylesheet" type="text/css" href="{{ base_path().'/location/css/bootstrap.min.css' }}">
Upvotes: 0
Reputation: 11636
barryvdh/laravel-dompdf does not support boostrap yet.
Quoting the author:
I highly doubt that DomPDF can handle Bootstrap correctly. If you need better pdf, try: https://github.com/barryvdh/laravel-snappy That used Webkit to render pdf.
See more about the issue here
Upvotes: 2