From 93148ef9afa3ad3c9b1de6ca2d5b198270d2c861 Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Fri, 2 Jan 2026 20:43:59 +0200 Subject: [PATCH] fix: Use SVG data URI for QR code (no GD extension required) Generate QR as SVG and encode as base64 data URI for embedding in PDF. This avoids dependency on GD extension while keeping QR codes in PDF. --- app/Services/QrStickerService.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Services/QrStickerService.php b/app/Services/QrStickerService.php index 36721a3..4be5455 100644 --- a/app/Services/QrStickerService.php +++ b/app/Services/QrStickerService.php @@ -85,16 +85,19 @@ class QrStickerService */ private function generatePdf(Order $order, string $qrUrl): string { - // Generate QR code as base64-encoded PNG (DomPDF handles this better than SVG) + // Generate QR code as SVG, then convert to data URI $options = new QROptions([ - 'outputType' => QRCode::OUTPUT_IMAGE_PNG, + 'outputType' => QRCode::OUTPUT_MARKUP_SVG, 'eccLevel' => QRCode::ECC_H, - 'scale' => 8, - 'imageBase64' => true, + 'scale' => 4, + 'imageBase64' => false, ]); $qrCode = new QRCode($options); - $qrBase64 = $qrCode->render($qrUrl); + $qrSvg = $qrCode->render($qrUrl); + + // Convert SVG to data URI for embedding in HTML + $qrDataUri = 'data:image/svg+xml;base64,' . base64_encode($qrSvg); // Determine order type $orderType = $order->type === 'standard' ? 'STOCK ORDER' : 'CUSTOM ORDER'; @@ -254,7 +257,7 @@ class QrStickerService