1 Commits

Author SHA1 Message Date
dhanabalan
b0d2132e25 Refactor QR code PDF generation to improve layout and add automatic print functionality 2025-07-28 18:01:50 +05:30
2 changed files with 24 additions and 46 deletions

View File

@@ -1,30 +0,0 @@
name: Laravel Pint
on:
pull_request:
workflow_dispatch:
jobs:
pint:
runs-on: ubuntu-latest
steps:
# Reinstall system libraries to ensure compatibility
- name: Ensure system libraries are up-to-date
run: |
sudo apt-get update
sudo apt-get install --reinstall --yes git libc6
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
# Run pint in test mode, check only files different from master branch
- name: Run Laravel Pint in test mode
run: vendor/bin/pint --test --diff=master

View File

@@ -24,15 +24,15 @@ class PalletController extends Controller
$qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary);
$html = '
return '
<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: 6mm; padding-top: 2mm; }
.text-cell { text-align: left; vertical-align: middle; font-size: 15pt; padding-left: 4mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
img.qr { width: 18mm; height: 18mm; display: block; }
.qr-cell { width: 14mm; text-align: right; vertical-align: bottom; padding-left: 4mm; padding-top: -6mm; }
.text-cell { text-align: left; vertical-align: middle; font-size: 16pt; padding-left: 4mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
img.qr { width: 13mm; height: 13mm; display: block; }
</style>
</head>
<body>
@@ -46,23 +46,31 @@ class PalletController extends Controller
</td>
</tr>
</table>
<script>
window.onload = function () {
window.print();
setTimeout(function () {
window.close();
}, 500); // Wait 0.5 seconds before closing
};
</script>
</body>
</html>
';
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => [60, 14],
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'tempDir' => '/var/www/storage/mpdf-tmp',
]);
// $mpdf = new Mpdf([
// 'mode' => 'utf-8',
// 'format' => [60, 14],
// 'margin_left' => 0,
// 'margin_right' => 0,
// 'margin_top' => 0,
// 'margin_bottom' => 0,
// // 'tempDir' => '/var/www/storage/mpdf-tmp',
// ]);
$mpdf->WriteHTML($html);
$mpdf->Output('qr-label.pdf', 'I');
exit;
// $mpdf->WriteHTML($html);
// // Output PDF to browser for printing
// $mpdf->Output('qr-label.pdf', 'I');
}
/**