diff --git a/app/Services/QrStickerService.php b/app/Services/QrStickerService.php index ab235c7..36721a3 100644 --- a/app/Services/QrStickerService.php +++ b/app/Services/QrStickerService.php @@ -85,16 +85,16 @@ class QrStickerService */ private function generatePdf(Order $order, string $qrUrl): string { - // Generate inline QR code as SVG + // Generate QR code as base64-encoded PNG (DomPDF handles this better than SVG) $options = new QROptions([ - 'outputType' => QRCode::OUTPUT_MARKUP_SVG, + 'outputType' => QRCode::OUTPUT_IMAGE_PNG, 'eccLevel' => QRCode::ECC_H, - 'scale' => 4, - 'imageBase64' => false, + 'scale' => 8, + 'imageBase64' => true, ]); $qrCode = new QRCode($options); - $qrSvg = $qrCode->render($qrUrl); + $qrBase64 = $qrCode->render($qrUrl); // Determine order type $orderType = $order->type === 'standard' ? 'STOCK ORDER' : 'CUSTOM ORDER'; @@ -111,15 +111,14 @@ class QrStickerService $nameParts = explode(' ', trim($customerName)); $customerSurname = end($nameParts); - // Build HTML directly (no view file dependency) - $html = << + // Build HTML with proper SVG embedding (avoid heredoc issues) + $html = ' @@ -231,49 +227,47 @@ class QrStickerService
- {$orderType} -
{$order->order_number}
+ ' . htmlspecialchars($orderType) . ' +
' . htmlspecialchars($order->order_number) . '
Customer
-
{$customerSurname}
+
' . htmlspecialchars($customerSurname) . '
Design: - - {$this->truncate($designName, 12)} - + ' . htmlspecialchars($this->truncate($designName, 12)) . '
Date: - {$order->created_at->format('M d')} + ' . htmlspecialchars($order->created_at->format('M d')) . '
Status: - - {$this->formatStatus($order->status)} - + ' . htmlspecialchars($this->formatStatus($order->status)) . '
- {$qrSvg} + QR Code
- -HTML; +'; try { $pdf = Pdf::loadHTML($html); - $pdf->setPaper([0, 0, 420.94, 297.64], 'portrait'); + // Set to A6 size (105mm × 148mm) in portrait orientation + // 105mm = 297.64 points, 148mm = 420.94 points + $pdf->setPaper([0, 0, 297.64, 420.94], 'portrait'); + $pdf->setOption('isRemoteEnabled', true); $filename = "{$order->uuid}.pdf"; $path = "qr-stickers/{$filename}"; diff --git a/storage/framework/views/619d5e9672f11af17a444b83f0b1beea.php b/storage/framework/views/619d5e9672f11af17a444b83f0b1beea.php new file mode 100644 index 0000000..70b4414 --- /dev/null +++ b/storage/framework/views/619d5e9672f11af17a444b83f0b1beea.php @@ -0,0 +1,83 @@ + + +startSection('content'); ?> +
+

QR Sticker Preview

+ +
+ +
+

Order Details

+ +
+
+

Order Number

+

order_number); ?>

+
+ +
+

UUID

+

uuid); ?>

+
+ +
+

Status

+

status)); ?>

+
+ +
+

Customer

+

user?->name ?? 'N/A'); ?>

+
+ +
+

Created

+

created_at->format('M d, Y H:i')); ?>

+
+ + items->count() > 0): ?> +
+

Design

+

items->first()?->product?->name ?? 'Custom'); ?>

+
+ + +
+

Sticker Path

+

+
+
+ + + + 📥 Download PDF + +
+ + +
+

PDF Preview (A6 Sticker)

+ +
+ +
+ +

+ If the PDF doesn't display above, it may be loading. Try refreshing or downloading the PDF directly. +

+
+
+ + +
+ ← Back to Home +
+
+stopSection(); ?> + +make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?> \ No newline at end of file