diff --git a/app/Http/Controllers/TestingPanelController.php b/app/Http/Controllers/TestingPanelController.php index c9ee691..a181bff 100644 --- a/app/Http/Controllers/TestingPanelController.php +++ b/app/Http/Controllers/TestingPanelController.php @@ -10,7 +10,10 @@ use DB; use Filament\Notifications\Notification; use Illuminate\Http\Request; 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 { @@ -21,90 +24,131 @@ class TestingPanelController extends Controller { // } +public function downloadQrPdf($palletNo) +{ + // 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); - public function downloadQrPdf($palletNo) - { - $qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed - $qrBase64 = base64_encode($qrBinary); + // Prepare HTML with embedded QR code + $html = ' + + + + + + + + + + +
+ QR + + ' . htmlspecialchars($palletNo) . ' +
+ + + '; - $html = ' - - - - - - - - - - -
- QR - - ' . htmlspecialchars($palletNo) . ' -
- - - '; + $mpdf = new Mpdf([ + 'mode' => 'utf-8', + 'format' => [60, 14], + 'margin_left' => 0, + 'margin_right' => 0, + 'margin_top' => 0, + 'margin_bottom' => 0, + ]); - $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->Output('qr-label.pdf', 'I'); + exit; +} - $mpdf->WriteHTML($html); - $mpdf->Output(); // This directly flushes output as PDF - exit; + // public function downloadQrPdf($palletNo) + // { + // $qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed + // $qrBase64 = base64_encode($qrBinary); - // $mpdf->WriteHTML($html); + // $html = ' + // + // + // + // + // + // + // + // + // + // + //
+ // QR + // + // ' . htmlspecialchars($palletNo) . ' + //
+ // + // + // '; - // 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"' - // ]); - } + // $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->Output(); // This directly flushes output as PDF + // exit; + + // } // public function downloadQrPdf($palletNo)