Reputation: 4029
my project is on laravel 5.4
I use qr code package to generate qr code. my goal is to make the qr code, then send it to view(which will be converted to pdf). is it possible to send this code without saving it in file?
//here I generate qr code
$qrCode = new QrCode($qrCodeString);
$qrCode->setSize(200);
$qrCode->setWriterByName('png');
$qrCode->setEncoding('UTF-8');
// then I create pdf from html, where I want to attach qr code
$pdf = \PDF::loadView('pdf-view', [
'username' => $username,
'qrcode' => $qrCode
]);
for now its like a raw file, if I try to print it in html, it looks like
b"""
ëPNG\r\n
\x1A\n
\x00\x00\x00\rIHDR\x00\x00\x00▄\x00\x00\x00▄\x08\x02\x00\x00\x00ö8XÍ\x00\x00\x00\tpHYs\x00\x00\x0E─\x00\x00\x0E─\x01ò+\x0E\e\x00\x00\x06IIDATx£Ý¦█v┌0\x10Fßðı¸\x7FÕ¶ûài¡Nµ░%÷wMl\x03\x7FóîÄÅ´´´/ëõζ\x03H»\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp~▀¥Ô±x4<Ã?\x04\x06B▀>¾╦uV^\x13╗‗è¼'\³vb?Uõ÷Ò‗/Ñp\fÑp\fÑp\fÑp\fÑp¯½oܼ·w±Ô+W^)f│«3Ì\x19Ê \x18╩ó¨Û؃°§-\x00´^ÎI┤‗H)\x02¤c¾-\x1CC)\x1CC)\x1CC)££Ûø÷¤§è┼g╬¬~½Ü\x07┐˲║äVÌs°sIÖ┤qòò╚ʸ╬a¾-\x1CC)\x1CC)\x1CC)£²\n
رJ?kñ;v»Â╣±â÷\vÕÄbÖÏ«\x17)ï═Àp\fÑp\fÑp\fÑp,tfäïÿO¿~÷\vel╬vÓ\x05Ú?¿E6▀┬1ö┬1ö┬1ö┬┘»ðëòƒëEkýRûGÙrBy'Ì╣ë^l▓Eæ┴´Èµ[8åR8åR8åR8┴Bç?\x02K[»\x1D█Q¡│┌Ó|º¹u\t¢òÁ;\x19Ý5+Pøýº░¨\x16Äí\x14Äí\x14Äí\x14╬!à╬Ä╗à´°╠=¯CI\eÎN▄½<Õ¡┼vBâ\x1FD7╦µ[8åR8åR8åR8├þ}´8Dv;B\r|\x17▒g.z═¡C║ä«RéRZ5\x17EÖVÚ\x07Ï|\vÃP\n
ÃP\n
ÃP\n
g©ð®¹\x1F£?Ë;K¦B°®Ð¨G¦¨Y▒Û2Ñïí¡¾bQ¾╗╚·®Ïu~■\x19┌|\vÃP\n
ÃP\n
ÃP\n
gxý;v╗║¬╣s\;÷.ã7Ø\v▄ï;÷M\eôm~×@©c╗╗w÷r\x14▒¨\x16Äí\x14Äí\x14Äí\x14Naí\x03ƒ[║°x│u+ݺz\x04CÖÁ;wÐ.▀Ñe#\x7FÊF█ÌÚE\x1Fà═Àp\fÑp\fÑp\fÑpX{×ù×é¦6>■╔÷[¸\x1D¹‗Ä<¾+<¸Ô\x13~\x01l¥àc(àc(àc(à3╣¯\e8·\tÙ¼AÎ─{Ñê}âÀosxý¹÷╩u_g8\x01gÈ┐õwa¾-\x1CC)\x1CC)\x1CC)££Û;▒ĵ¤ú¯\x1CgŦ}¸[\x17×8Vwµ§ÓhxþÌÚ┤ò‗oU³·┘|\vÃP\n
ÃP\n
ÃP\n
'©Ù\x1AyÉ*WVo@¦6Ì1Y¾þ+µßO¯║Â‗\x1AÓ<¾öq ╬>ì+Ó¨k¤l¥àc(àc(àc(àËÀ¯╗tÀN³u▀)ƒO©Î\x05┤þ9ÝïI┴\x1F}µ?aÇ═Àp\fÑp\fÑp\fÑpÊ\n
\x1D~MzU7■[g÷ä¶ö+W¡¹«C;\x7F<å÷\v┘ÂÜ>|»g6▀┬1ö┬1ö┬1ö┬┴Ø8vã©vý▄p°jqð║´ÀhÙÁÙNË\x1E4~ÌwÓ:ü\x17\┘|\vÃP\n
ÃP\n
ÃP\n
þÐv£Q®║═┤f═>sþÓõ│╚«ku5Ó\x15k(:Ù<▒ÃáÞ╗p¦À>ùí\x14Äí\x14Äí\x14╬$▀µ#¢è¯ı6Ñw|è;w¦wl ┤½Ê\n
=%(Ø{òÎØÇFø\x06\x7F╦µ[8åR8åR8åR8}{×7\x0F\x18\x1E░Ùx°\x1C7┌( fÙ¥\x07\v├╬¾¥\x13Gì?a§║═Àp\fÑp\fÑp\fÑp\n
¤¹N\x1Ci\f\9v»ö\x7FÝKÎt{̸\x1EÛfDÎòƒÒþ»e¢ÁèÌ\x00øoß\x18Jß\x18Jß\x18JßÓv]#▀Þo¸¬Ùg¿CÌ´²Ï▒´┴¡¸hUs;©¯[ƒ╦P\n
ÃP\n
ÃP\n
þÉu▀ØW×¢u¦<sN @N(ùDh\v\x00Vý°╠+~̺a¾-\x1CC)\x1CC)\x1CC)£\x13&¨~U×n¦¯P\x07êýy\x1E3¥\x1E Ñ┌¦tãxÍF\f==\x066▀┬1ö┬1ö┬1ö┬\t¯║ÍiÂ■\r╠ð\x0E´ûV¶<ïÀ«½D;÷<\x07Ôƒ¸¦yû┘¯l¥àc(àc(àc(àsHí\x13É8C;kÄs¦\x08■¼ª=¤ï║iÇ3$hu}█\x08~Íu\x02Oh¾-\x1CC)\x1CC)\x1CC)£┬=¤Wðãm\x17oÀØ¢Ì┼þv\t¢5x×\x17|'┤N6▀┬1ö┬1ö┬1ö┬9ñð┘±┐¹\x03F║ï\x1EµÉP^¦v\x12┼Vpg=╠x]O>7▄µ[8åR8åR8åR8Ã\x16:/\x16 æþƒ¸\x1D~\x00°òƒ}J(iã¸á╦R±╦f¾-\x1CC)\x1CC)\x1CC)£c\vØö\n
▒f¤:)îÂ\x07{Ós«Z¸²┐À®vã\x17\x1CPzÍ█È.p6▀┬1ö┬1ö┬1ö┬\t\x16:Òú[/h¤3¿nçÂ\x0F¨Ï.í\x14ë3ã\x033ßŨMsµ╣Âg(àc(àc(à¾8`¿Mç±/Ñp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp\fÑp■\x00UaA╔ ├HÖ\x00\x00\x00\x00IEND«B`é
"""
if I save file first and then just indicate the url of file in html (like <img src='pathToFile'
), it works fine, but is there way to show this file in view without saving it?
Upvotes: 1
Views: 2516
Reputation: 12452
You could convert the content of the image to an base64
string and then put it in the src
of the img
tag. For example somehow like this:
$base64Image = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
echo '<img src="data:image/png;base64,' . $base64Image . '" />';
Upvotes: 3