From 5dfb63dacbf1d8ea14daad27255ab4793bea0cc1 Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Fri, 2 Jan 2026 20:42:19 +0200 Subject: [PATCH] fix: Use base64-encoded PNG for QR code in PDF stickers DomPDF renders embedded PNG images more reliably than inline SVG. Changed QR code generation to OUTPUT_IMAGE_PNG with base64 encoding, then embed as img tag in the PDF HTML. --- app/Services/QrStickerService.php | 56 ++++++------- .../619d5e9672f11af17a444b83f0b1beea.php | 83 +++++++++++++++++++ 2 files changed, 108 insertions(+), 31 deletions(-) create mode 100644 storage/framework/views/619d5e9672f11af17a444b83f0b1beea.php 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