pallet pdf issue solved package
This commit is contained in:
@@ -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,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)
|
// Prepare HTML with embedded QR code
|
||||||
{
|
$html = '
|
||||||
$qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed
|
<html>
|
||||||
$qrBase64 = base64_encode($qrBinary);
|
<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>
|
||||||
|
';
|
||||||
|
|
||||||
$html = '
|
$mpdf = new Mpdf([
|
||||||
<html>
|
'mode' => 'utf-8',
|
||||||
<head>
|
'format' => [60, 14],
|
||||||
<style>
|
'margin_left' => 0,
|
||||||
body {
|
'margin_right' => 0,
|
||||||
margin: 0;
|
'margin_top' => 0,
|
||||||
padding: 0;
|
'margin_bottom' => 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([
|
$mpdf->WriteHTML($html);
|
||||||
'mode' => 'utf-8',
|
$mpdf->Output('qr-label.pdf', 'I');
|
||||||
'format' => [60, 14],
|
exit;
|
||||||
'margin_left' => 0,
|
}
|
||||||
'margin_right' => 0,
|
|
||||||
'margin_top' => 0,
|
|
||||||
'margin_bottom' => 0,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$mpdf->WriteHTML($html);
|
// public function downloadQrPdf($palletNo)
|
||||||
$mpdf->Output(); // This directly flushes output as PDF
|
// {
|
||||||
exit;
|
// $qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed
|
||||||
|
// $qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
// $mpdf->WriteHTML($html);
|
// $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>
|
||||||
|
// ';
|
||||||
|
|
||||||
// return response($mpdf->Output('qr-code.pdf', 'S'), 200, [
|
// $mpdf = new Mpdf([
|
||||||
// 'Content-Type' => 'application/pdf',
|
// 'mode' => 'utf-8',
|
||||||
// //'Content-Disposition' => 'attachment; filename="qr-code.pdf"'
|
// 'format' => [60, 14],
|
||||||
// 'Content-Disposition' => 'inline; filename="qr-code.pdf"'
|
// '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)
|
// public function downloadQrPdf($palletNo)
|
||||||
|
|||||||
Reference in New Issue
Block a user