SVG QR Code Generator In JavaScript

Category: Javascript | July 11, 2022
Author:shlyren
Views Total:1,172 views
Official Page:Go to website
Last Update:July 11, 2022
License:MIT

Preview:

SVG QR Code Generator In JavaScript

Description:

A feature-rich, cross-platform SVG QR code generator for both node.js and browser.

How to use it:

1. Install and download.

# NPM
$ npm i qrcode-svg-ts

2. Import the qrcode-svg-ts.

var QRCode = require("qrcode-svg-ts");
// OR
<script src="./dist/qrcode-svg-ts.min.js"></script>

3. Generate an SVG QR Code.

var svg = new QRCode("CSS Script").svg();

4. Available options to customize the QR Code.

var qrcode = new QRCode({
    content: "CSS Script",
    padding: 0,
    width: 256,
    height: 256,
    typeNumber: 4,
    color: "#000000",
    background: "#ffffff",
    ecl: "H", // L, M, H, Q
    join: true,
    predefined: false,
    pretty: true,
    swap: false, // swap X and Y modules
    xmlDeclaration: true, // prepend XML declaration to the SVG document
    container: 'svg', // wrapping element
});

5. Save the QR Code.

qrcode.save("sample.svg").then(() => {
  console.log('Saved')
}).catch(console.err)

You Might Be Interested In:


Leave a Reply