Good evening, next, I'm going through a PDF printing problem, I made a system in Laravel where I need to print a list of a specific template, and I'm using lib:
All right until then.
The problem is when I'm asking to save the saved file in PDF, but it always comes corrupted.
Follow the implementation
view.blade.php
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 12px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
</style>
</head>
<body>
<h1>Produtos</h1>
<div class="flex-center position-ref full-height">
<table>
<thead>
<tr>
<th>Id</th>
<th>Descrição</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Descricao</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Controller.php
public function print(){
return PDF::loadView('view')
->setPaper('a4', 'landscape')
->download('impressao.pdf');
}
As you can see, the call is very simple, I'm just trying to print a test page, and then try to insert the data. But the file always gets corrupted. I have already tried to use streem in place of the download to display the PDF directly in the browser, but still continue with the error. Thanks in advance for your help.