pallet pdf issue solved package

This commit is contained in:
dhanabalan
2025-07-01 13:47:52 +05:30
parent e083c0e4a5
commit fb29148011

View File

@@ -10,7 +10,10 @@ use DB;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Mpdf\Mpdf; use Mpdf\Mpdf;
use SimpleSoftwareIO\QrCode\Facades\QrCode; use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Output\QROutputInterface;
use Mpdf\QrCode\Output;
use Mpdf\QrCode\QrCode;
class TestingPanelController extends Controller class TestingPanelController extends Controller
{ {
@@ -21,52 +24,24 @@ class TestingPanelController extends Controller
{ {
// //
} }
public function downloadQrPdf($palletNo) public function downloadQrPdf($palletNo)
{ {
$qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed // Generate QR code as PNG binary (adjust size as needed)
$qrCode = new QrCode($palletNo);
$output = new Output\Png();
$qrBinary = $output->output($qrCode, 100); // 100px size
$qrBase64 = base64_encode($qrBinary); $qrBase64 = base64_encode($qrBinary);
// Prepare HTML with embedded QR code
$html = ' $html = '
<html> <html>
<head> <head>
<style> <style>
body { body { margin: 0; padding: 0; width: 60mm; height: 14mm; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
margin: 0; .sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; }
padding: 0; .qr-cell { width: 14mm; text-align: left; vertical-align: middle; padding-left: 5mm; padding-top: 2mm; }
width: 60mm; .text-cell { text-align: left; vertical-align: middle; font-size: 12pt; padding-left: 7mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
height: 14mm; img.qr { width: 10mm; height: 10mm; display: block; }
font-size: 10pt;
font-family: DejaVu Sans, sans-serif;
}
.sticker-table {
width: 60mm;
height: 14mm;
border-collapse: collapse;
}
.qr-cell {
width: 14mm;
text-align: left;
vertical-align: middle;
padding-left: 5mm;
padding-top: 2mm;
}
.text-cell {
text-align: left;
vertical-align: middle;
font-size: 12pt;
padding-left: 7mm;
padding-top: 2mm;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: bold;
}
img.qr {
width: 10mm;
height: 10mm;
display: block;
}
</style> </style>
</head> </head>
<body> <body>
@@ -94,17 +69,86 @@ class TestingPanelController extends Controller
]); ]);
$mpdf->WriteHTML($html); $mpdf->WriteHTML($html);
$mpdf->Output(); // This directly flushes output as PDF $mpdf->Output('qr-label.pdf', 'I');
exit; exit;
}
// public function downloadQrPdf($palletNo)
// {
// $qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed
// $qrBase64 = base64_encode($qrBinary);
// $html = '
// <html>
// <head>
// <style>
// body {
// margin: 0;
// padding: 0;
// width: 60mm;
// height: 14mm;
// font-size: 10pt;
// font-family: DejaVu Sans, sans-serif;
// }
// .sticker-table {
// width: 60mm;
// height: 14mm;
// border-collapse: collapse;
// }
// .qr-cell {
// width: 14mm;
// text-align: left;
// vertical-align: middle;
// padding-left: 5mm;
// padding-top: 2mm;
// }
// .text-cell {
// text-align: left;
// vertical-align: middle;
// font-size: 12pt;
// padding-left: 7mm;
// padding-top: 2mm;
// white-space: nowrap;
// overflow: hidden;
// text-overflow: ellipsis;
// font-weight: bold;
// }
// img.qr {
// width: 10mm;
// height: 10mm;
// display: block;
// }
// </style>
// </head>
// <body>
// <table class="sticker-table">
// <tr>
// <td class="qr-cell">
// <img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
// </td>
// <td class="text-cell">
// ' . htmlspecialchars($palletNo) . '
// </td>
// </tr>
// </table>
// </body>
// </html>
// ';
// $mpdf = new Mpdf([
// 'mode' => 'utf-8',
// 'format' => [60, 14],
// 'margin_left' => 0,
// 'margin_right' => 0,
// 'margin_top' => 0,
// 'margin_bottom' => 0,
// ]);
// $mpdf->WriteHTML($html); // $mpdf->WriteHTML($html);
// $mpdf->Output(); // This directly flushes output as PDF
// exit;
// return response($mpdf->Output('qr-code.pdf', 'S'), 200, [ // }
// 'Content-Type' => 'application/pdf',
// //'Content-Disposition' => 'attachment; filename="qr-code.pdf"'
// 'Content-Disposition' => 'inline; filename="qr-code.pdf"'
// ]);
}
// public function downloadQrPdf($palletNo) // public function downloadQrPdf($palletNo)