Closed sviluppatoreLaRegione closed 3 years ago
Hi @sviluppatoreLaRegione please provide some information on what version of the library you are using, what writer and settings / options and an example of the problematic output so I can check or reproduce the issue.
This is the code that I use:
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Endroid\QrCode\QrCode;
$codes = "1234-5678-9ABC-DEFG-HILMN-OPQR\n1234-5678-9ABC-DEFG-HILMN-OPQR";
$qrCode = new QrCode($codes);
$qrCode->setSize(1000);
$qrCode->setMargin(0);
$qrCode->setRoundBlockSize(false);
$qrCode->setValidateResult(true);
$qrCode->writeFile(__DIR__.'/qrcode.png');
$box = '
<table style="border: 1px solid black; border-radius: 5px;">
<tr>
<td style="font-size: 30px; padding: 10px;">
'.nl2br($codes).'
</td>
<td style="padding: 10px;">
<img src="http://etlux.test/qrcode.png" width="145px">
</td>
</tr>
</table>
';
if(isset($_GET['pdf'])) :
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($box);
$mpdf->Output();
die;
endif;
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>App</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<h1>ETLUX</h1>
<?= $box ?>
<p style="font-size: 30px;"><a href="index.php?pdf">Genera PDF</a></p>
</body>
</html>
The version from composer:
"require-dev": {
"endroid/quality": "^1.3.7",
"setasign/fpdf": "^1.8"
},
Thanks
Hi @sviluppatoreLaRegione I generated the code here following the exact same script.
$codes = "1234-5678-9ABC-DEFG-HILMN-OPQR\n1234-5678-9ABC-DEFG-HILMN-OPQR";
$qrCode = new QrCode($codes);
$qrCode->setSize(1000);
$qrCode->setMargin(0);
$qrCode->setRoundBlockSize(false);
$qrCode->setValidateResult(true);
$qrCode->writeFile(__DIR__.'/qrcode.png');
And I got this result. As you can see a perfectly white / black image. So image generation from this library seems OK so you should look at the PDF generation or display.
Yeah, I see... something get wrong when image is resized and added on PDF. Thanks
I am not sure if this it's an issue with this library or another one where I add the QR Code generated to a PDF, but seem that the qr-code is not totally black and white but has some shades of gray. It's possible to fix this?
Thanks