Flexible Client-side QR Code Generator

Category: Javascript , Recommended | September 1, 2024
Author:nayuki
Views Total:4,479 views
Official Page:Go to website
Last Update:September 1, 2024
License:MIT

Preview:

Flexible Client-side QR Code Generator

Description:

Just another flexible, customizable, client-side QR code generator built using TypeScript. Also supports Java, Python, Rust, C, 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:

09/01/2024

  • Slightly simplified the calculation of alignment pattern spacing in a non-obvious way

09/17/2022

  • Updated JavaScript version.

07/29/2021

  • Added new public functions QrSegment.{isNumeric(),isAlphanumeric()} and privatized the regexes in {Java, TypeScript, Python}, because the regexes are awkward compared to a clean abstraction.

11/05/2018

  • Reordered calls to applyMask()/drawFormatBits() for conceptual clarity, without changing output (because masks don’t affect format bits), in all language versions.

11/02/2018

  • Simplified a bit of code in JavaScript, TypeScript, Python.

10/29/2018

  • Tweaked JavaScript code to use String.substring() instead of the deprecated non-standard substr().

10/27/2018

  • Completely rewrote the algorithm for detecting finder-like patterns, making it more accurate and compliant with the QR Code specification, in all languages.

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.

You Might Be Interested In:


Leave a Reply