Demonstration - DataMatrix
Capable of being read by most mobile phones.
Generally used to label and track small items for inventory.
Has a very low error rate with internal error correction.
Barcode can be square or rectangular in shape.
'use strict';
import { createServer } from 'http';
import { BCGColor, BCGDrawing, createSurface, toBuffer } from '@barcode-bakery/barcode-nodejs';
import { BCGdatamatrix } from '@barcode-bakery/barcode-nodejs/datamatrix';
http.createServer(function (request, response) {
const colorBlack = new BCGColor(0, 0, 0);
const colorWhite = new BCGColor(255, 255, 255);
// Barcode Part
const code = new BCGdatamatrix();
code.setScale(2); // Resolution
code.setForegroundColor(colorBlack); // Color of bars
code.setBackgroundColor(colorWhite); // Color of spaces
code.parse('Datamatrix');
// Drawing Part
const drawing = new BCGDrawing(createSurface);
toBuffer(drawing, BCGDrawing.ImageFormat.Png, function (err, buffer) {
response.writeHead(200, { "Content-Type": "image/png" });
response.end(buffer);
});
}).listen(8124);