datalog / datamatrix-svg

Data Matrix generator is for fast creation of rectangular or square 2D codes. Written on vanilla javascript with no dependencies.
MIT License
134 stars 49 forks source link

Specific Data Matrix sizes? #7

Open thereddestdog opened 7 months ago

thereddestdog commented 7 months ago

How could I generate a 12x26 2D barcode, for example?

ChuckTerry commented 7 months ago

Here's some sample code for you:

// msg must be a certain length to generate 12x26, that length varies depending on character/number makeup
// rct indicates that you want a rectangle rather than a square
const options = {
  msg :  "Bacon is grand!",
  rct :   1
};

// Generate the SVG
const svg = DATAMatrix(options);

// Append it to something
document.body.appendChild(svg);

You can also check out the Live Demo for real-time generation.