Skip to content

Instantly share code, notes, and snippets.

@eni23
Created May 19, 2017 14:10
Show Gist options
  • Save eni23/cadfb0f82573373e7add12cbf45bae4f to your computer and use it in GitHub Desktop.
Save eni23/cadfb0f82573373e7add12cbf45bae4f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test bc</title>
<!--
Get it from: https://github.com/metafloor/bwip-js
!-->
<script type="text/javascript" src="./freetype.js"></script>
<script type="text/javascript" src="./bwipp.js"></script>
<script type="text/javascript" src="./bwipjs.js"></script>
<script type="text/javascript" src="./lib/bitmap.js"></script>
</head>
<body>
<canvas id="canvas"></canvas>
</body>
<script>
var freetype = Module;
var generate_datamatrix = function( opts ){
var scale = opts.scale || 2;
var rotation = opts.rotation || "N";
var bctype = opts.type || "datamatrix";
console.log(opts);
var canvas = document.getElementById(opts.target_elem);
var bw = new BWIPJS(freetype, false);
bw.bitmap(new Bitmap);
bw.scale(scale, scale);
var bwopts = {
parsefnc:true,
includetext:false
};
BWIPP()(bw, bctype, opts.data, bwopts);
bw.bitmap().show(canvas, rotation);
}
generate_datamatrix({
"target_elem": "canvas",
"data": "https://c.e23.ch/A47D/1E20786A/001",
"scale": 1.9,
"type": "datamatrix"
})
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment