pallet pdf issue solved package
This commit is contained in:
@@ -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,52 +24,24 @@ class TestingPanelController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed
|
||||
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);
|
||||
|
||||
// Prepare HTML with embedded QR code
|
||||
$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;
|
||||
}
|
||||
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>
|
||||
@@ -94,17 +69,86 @@ class TestingPanelController extends Controller
|
||||
]);
|
||||
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output(); // This directly flushes output as PDF
|
||||
$mpdf->Output('qr-label.pdf', 'I');
|
||||
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->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)
|
||||
|
||||
Reference in New Issue
Block a user