Created
September 18, 2022 11:25
-
-
Save fuadarradhi/84042d34dacf3e0de27d6251f1f8391f to your computer and use it in GitHub Desktop.
Generate QRCode without save - MPDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install | |
composer require mpdf/mpdf | |
composer require mpdf/qrcode | |
# load qrcode library | |
$qrCode = new Mpdf\QrCode\QrCode("text to be generate here"); | |
$output = new Mpdf\QrCode\Output\Png(); | |
# generate base64 image qrcode | |
$qrcode_base64 = 'data:image/png;base64,' . base64_encode($output->output($qrCode, 100, [255, 255, 255], [0, 0, 0])); | |
# show base64 image | |
$html = '<img src="'.$qrcode_base64.'"/>'; | |
# load mpdf library | |
$mpdf = new \Mpdf\Mpdf(['format' => [210, 150]]); | |
$mpdf->WriteHTML($html); | |
$mpdf->Output(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment