php - QR CODE not printing -
i generating qr code url data content, when try print page qr generated, qr not seem appear yet other content displays. here snippet
<?php require_once("qrcode.php"); //--------------------------------------------------------- $qr = new qrcode(); // ƒgƒ‰[’ù³ƒŒƒxƒ‹‚ðÝ’è // qr_error_correct_level_l : 7% // qr_error_correct_level_m : 15% // qr_error_correct_level_q : 25% // qr_error_correct_level_h : 30% $qr->seterrorcorrectlevel(qr_error_correct_level_l); $qr->settypenumber(4); $qr->adddata("http:/".$_server['request_uri'].""); $qr->make(); //--------------------------------------------------------- ?>
and below other content on page
<div class="invoice-box" id="invoice-box"> <table cellpadding="0" cellspacing="0"> <tr class="top"> <td colspan="2"> <table> <tr> <td class="title"> <img src="images/logo.png" style="width:100%; max-width:200px; height:95px;"> </td> <td> invoice #: <?php print $invoice_details->sub_code ?><br> created: <?php print date('y/m/d', strtotime($invoice_details->paid_date)) ?><br> due: february 1, 2015 </td> </tr> </table> </td> </tr> <tr class="information"> <td colspan="2"> <table> <tr> <td> <br> <br> </td> <td> <?php print $invoice_details->org ?><br> <?php print $invoice_details->lname ?> <?php print $invoice_details->fname ?><br> <?php print $invoice_details->email ?> </td> <td> <?php $qr->printhtml(); ?> </td> </tr> </table> </td> </tr> <tr class="heading"> <td> payment method </td> <td> </td> </tr> <tr class="details"> <td> <?php print $invoice_details->method ?> </td> <td> </td> </tr> <tr class="heading"> <td> item </td> <td> price(ugx) </td> </tr> <tr class="item"> <td> <?php print ucfirst($invoice_details->event) ?> - summit </td> <td> <?php print number_format($invoice_details->amount) ?> </td> </tr> <tr class="total"> <td></td> <td> total: ugx <?php print number_format($invoice_details->amount) ?> </td> </tr> </table> </div> <input type="button" value="print div" onclick="printelem('#invoice-box')" />
and printing script
<script type="text/javascript"> function printelem(elem) { popup($(elem).html()); } function popup(data) { var mywindow = window.open('', 'invoice-box', 'height=400,width=600'); mywindow.document.write('<html><head><title>my div</title>'); /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />'); mywindow.document.write('</head><body >'); mywindow.document.write(data); mywindow.document.write('</body></html>'); mywindow.document.close(); // necessary ie >= 10 mywindow.focus(); // necessary ie >= 10 mywindow.print(); mywindow.close(); return true; } </script>
assuming found correct library, has image creator. need use output buffer around imagegif
(or imagepng
) call capture image's binary data string, base64 encode string, , echo part of data uri directly in src attribute of img tag.
$img = $qr->createimage(4, 2); ob_start(); imagegif($img); imagedestroy($img); $img = ob_get_clean();
in html
<img src="data:image/gif;base64,<?php echo base64_encode($img);?>">
if you're concerned support data urls, leave out output buffering, add unique, random filename second parameter imagegif
call save it, echo filename in src
.
Comments
Post a Comment