Cant see any problem at first glance, i would add this to the start of the page:
<!DOCTYPE html>
and maybe start to debug when the table gets broken, start with showing only 1 row, then slowly build up the table.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Guys I installed barryvdh/laravel-dompdf to convert html to pdf convertor for my report generation.
This is my controller
public function download()
{
$sales = Sales_details::all();
$pdf=PDF::loadView('Sales_details.view1',['sales'=>$sales]);
return $pdf->download('salesdetails1.pdf');
}
This is my view1.blade
<html>
<head>
<style>
table{border-collapse:collapse;
}
td,th
{
border:1px solid;
}
</style>
</head>
<body>
<caption><h2 align="center">SALES ENTRY PREVIEW</h2></caption><br>
<table>
<thead>
<th>ID</th>
<th>Date</th>
<th>Time</th>
{{-- <th>Customer Id</th> --}}
<th>Customer Type</th>
<th>Customer Name</th>
{{-- {{-- <th>Customer Location</th> --}}
<th>Customer Area</th>
<th>Customer Booth</th>
<th>Employee</th>
<th>Rate/Litre</th>
<th>No of Litres (Lt)</th>
<th>Total (Rs)</th>
</thead>
<tbody>
@foreach($sales as $sal)
<tr>
<td>{{ $sal->id }}</td>
<td>{{ $sal->date }}</td>
<td>{{ $sal->time }}</td>
{{-- <td>{{ $sal->customer_id }}</td> --}}
<td>{{ $sal->customer_type }}</td>
<td>{{ $sal->customer_name }}</td>
{{-- {{-- <td>{{ $sal->customer_location }}</td> --}}
<td>{{ $sal->customer_area }}</td>
<td>{{ $sal->customer_booth }}</td>
<td>{{ $sal->emp }}</td>
<td>{{ $sal->rate_per_litre }}</td>
<td>{{ $sal->no_of_litre }}</td>
<td>{{ $sal->total }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>
My problem is the tables are not correctly fitted in the pdf.
This the output pdf
Refer : https://imgur.com/a/SIhsDMo
What’s the problem kindly help me solve this. The data are displayed in the side of the page why?
And kindly someone help to convert my database into excel also. I tried Maatwebsite. But the syntax are not accepted due to version problem. I installed new version that is above 3.
In YouTube all the videos related to maatwebsite is lower version. So that is also problem
i need to copy my db into excel sheet also. Kindly help
Kindly suggest me idea for that to please..
<th> also needs to be wrapped in <tr>
<thead>
<tr>
<th>ID</th>
<th>Date</th>
<th>Time</th>
{{-- <th>Customer Id</th> --}}
<th>Customer Type</th>
<th>Customer Name</th>
{{-- <th>Customer Location</th> --}}
<th>Customer Area</th>
<th>Customer Booth</th>
<th>Employee</th>
<th>Rate/Litre</th>
<th>No of Litres (Lt)</th>
<th>Total (Rs)</th>
</tr>
</thead>
Please or to participate in this conversation.