Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
pure-svg-code
Advanced tools
Generate qrcode and barcode
Install from npm:
npm i pure-svg-code
Import it:
// import both
const {barcode,qrcode,svg2url} = require('pure-svg-code');
// import as you need
const barcode = require('pure-svg-code/barcode');
const qrcode = require('pure-svg-code/qrcode');
const svg2url = require('pure-svg-code/svg2url');
const svgString = qrcode({
content: "http://github.com/",
padding: 4,
width: 256,
height: 256,
color: "#000000",
background: "#ffffff",
ecl: "M"
})
Output svg content:
<?xml version="1.0" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="256" height="256">
<rect x="0" y="0" width="256" height="256" style="fill:#ffffff;shape-rendering:crispEdges;"/>
<rect x="35.310344827586206" y="35.310344827586206" width="8.827586206896552" height="8.827586206896552" style="fill:#000000;shape-rendering:crispEdges;"/>
<rect x="44.13793103448276" y="35.310344827586206" width="8.827586206896552" height="8.827586206896552" style="fill:#000000;shape-rendering:crispEdges;"/>
...
</svg>
content
- QR Code content, requiredpadding
- white space padding, 4
modules by default, 0
for no borderwidth
- QR Code width in pixelsheight
- QR Code height in pixelscolor
- color of modules, color name or hex string, e.g. #000000
background
- color of background, color name or hex string, e.g. white
ecl
- error correction level: L
, M
, H
, Q
Set it up and specify your type and options. The following 3 are the only required ones.
var svgString = barcode("9234567890128", "ean13", {width:'50', barWidth:1, barHeight:50});
Output svg content:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 50" >
<rect width="2.0" height="50" x="0.0" y="0"/>
<rect width="3.9" height="50" x="3.9" y="0"/>
...
</svg>
barHeight
height of svg (default: 30);width
width of svg (default: 100);bgColor
background color css like (default: 'transparent');color
barcode color (default: '#000000');showHRI
: should show text under bar;<img/>
tagconst {qrcode,svg2url} = require('pure-svg-code');
const svgString = qrcode('data');
const url = svg2url(svgString);
// set img element's src to url
imgEle.src = url;
This way can be used for browser & 小程序 or any client can render svg.
const {qrcode} = require('pure-svg-code');
app.get('/',function(req, res) {
const svgString = qrcode('data');
res.send(svgString)
})
FAQs
generate qrcode & barcode to svg in pure javascript
We found that pure-svg-code demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.