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.
This commit is contained in:
@@ -85,16 +85,19 @@ class QrStickerService
|
|||||||
*/
|
*/
|
||||||
private function generatePdf(Order $order, string $qrUrl): string
|
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([
|
$options = new QROptions([
|
||||||
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
|
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||||
'eccLevel' => QRCode::ECC_H,
|
'eccLevel' => QRCode::ECC_H,
|
||||||
'scale' => 8,
|
'scale' => 4,
|
||||||
'imageBase64' => true,
|
'imageBase64' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$qrCode = new QRCode($options);
|
$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
|
// Determine order type
|
||||||
$orderType = $order->type === 'standard' ? 'STOCK ORDER' : 'CUSTOM ORDER';
|
$orderType = $order->type === 'standard' ? 'STOCK ORDER' : 'CUSTOM ORDER';
|
||||||
@@ -254,7 +257,7 @@ class QrStickerService
|
|||||||
</div>
|
</div>
|
||||||
<div class="qr-section">
|
<div class="qr-section">
|
||||||
<div class="qr-code">
|
<div class="qr-code">
|
||||||
<img src="' . $qrBase64 . '" alt="QR Code" />
|
<img src="' . $qrDataUri . '" alt="QR Code" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user