Flexible Client-side QR Code Generator

Category: Javascript , Recommended | October 14, 2018
Author: nayuki
Views Total: 2,087
Official Page: Go to website
Last Update: October 14, 2018
License: MIT

Preview:

Flexible Client-side QR Code Generator

Description:

Just another flexible, customizable, client-side QR code generator built using pure JavaScript. Also supports Java, Python, and C++.

Main features:

  • Error correction level: Low, Medium, Quartile and High
  • Output format: bitmap or vector
  • Custom scale and border

How to use it:

Import the QR Code Generator’s JavaScript file into the html page.

<script src="qrcodegen.js"></script>

Basic usages:

// Name abbreviated for the sake of these examples here
var QRC = qrcodegen.QrCode;

// Simple operation
var qr0 = QRC.encodeText("Hello, world!", QRC.Ecc.MEDIUM);
var svg = qr0.toSvgString(4);

// Manual operation
var segs = qrcodegen.QrSegment.makeSegments("3141592653589793238462643383");
var qr1 = QRC.encodeSegments(segs, QRC.Ecc.HIGH, 5, 5, 2, false);

Changelog:

10/14/2018

  • Tweaked QrCode.drawFormatBits() to use end-exclusive range in second copy for clarity, in most languages.

10/09/2018

  • Simplified a bit of JavaScript and TypeScript code.

10/06/2018

  • Renamed QrSegment.getBits() to getData() in {Java, JavaScript, TypeScript, Python} code, to match C++ and Rust.

10/04/2018

  • Tweaked {JavaScript, TypeScript, HTML} code to encapsulate the application members.

10/02/2018

  • Tweaked the BitBuffer class top-level comment in all languages except C.
  • Tweaked BitBuffer.appendBits() comment in several language versions.

09/17/2018

  • Swapped {dy,dx} variables in commutative operations for clarity, in all languages.

09/01/2018

  • Reformatted some whitespace for alignment in all language versions.

08/28/2018

  • Added an assertion to QrCode.encodeSegmentsAdvanced() in all language versions.

Leave a Reply