javascript API for generating QR codes

2019-03-19 22:08发布

问题:

I am looking for a javascript API for generating QR codes (name, address and such) and outputting them in a printable format (png/jpeg/pdf). This seems to me to be something others before must have had a need for.

回答1:

Google has a QR code generator as part of their Chart Tools that you can use here.

http://code.google.com/apis/chart/infographics/docs/qr_codes.html



回答2:

jquery-qrcode jQuery plugin also generates QR code using HTML5 canvas element or HTML table, if canvas is not supported.

https://github.com/jeromeetienne/jquery-qrcode

$('#test').qrcode({
    width: 120,
    height: 120, 
    text: "https://github.com/jeromeetienne/jquery-qrcode"});

Working jsFiddle demo:

http://jsfiddle.net/maxim75/YwN8p/4/



回答3:

Maksym's solution is better than Google's library because it runs at local does not need to call Google API. also if you don't use jQuery, you can use this one at https://github.com/amanuel/JS-HTML5-QRCode-Generator



回答4:

Another HTML5 solution is http://davidshimjs.github.io/qrcodejs/ with IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile browser compatibility



回答5:

https://drive.google.com/open?id=0B3TWIbBcUUTwcE1vV24wQnRxNGs

above is the link of js file include it in your project and write the below code in ctp file in cake php or any where you want to use. i tested it in cake php...

<-- including the file....
<?php echo $this->Html->script('jquery.qrcode.min.js')?>
<div style='padding:100px''><img id="demo" style='width: 100px,height: 100px'></div>
<script type="text/javascript">jQuery("#demo").qrcode({text: "HEllo World!"});</script>