'Displaying QR Code in PDF file, in Laravel
I'm facing a problem with displaying a QR code in a PDF file. When I try to display the QR code without PDF it works. The QR code is generated by https://github.com/SimpleSoftwareIO/simple-qrcode on to a pdf file generated by https://github.com/barryvdh/laravel-dompdf/tree/0.8.5
StudentController.php:
public function view_downlads($id){
$pdf = PDF::loadView('Student.markscardpdf');
return $pdf->stream();
}
Student/markscardpdf.blade.php:
{{ QrCode::size(200)->generate('hello') }}
Solution 1:[1]
You can use library output within image tag by converting base64 format.
Example:
<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(200)->generate('http://google.com')) !!} ">
Solution 2:[2]
you can use like this, it will not require the imagick extension.
<img src="data:image/png;base64, {!! base64_encode(QrCode::size(200)->generate('http://google.com')) !!} ">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Md. Shoriful Islam |
| Solution 2 | Anjani Barnwal |
