Data Matrix

This is a software library that enables programs to write Data Matrix barcodes of the modern ECC200 variety.

Installation

def deps do
[
{:data_matrix, "~> 0.1.0"}
]
end

Rendering options

There are currently two formats available: :svg and :text.

SVG options

Option nameDefault value
widthauto
heightauto
viewboxfalse
module_size5
color"black"
background"white"

Text options

Option nameDefault value
zero"0"
one"1"
newline"\n"
separator""

Example

data = "123456"
svg =
data
|> DataMatrix.encode()
|> DataMatrix.format(:svg, color: "#6e4a7e", background: "aliceblue", width: 200)
File.write!("square.svg", svg)
Example square Data Matrix
matrix = DataMatrix.encode("A1B2C3D4E5F6G7H8I9J0K1L2", quiet_zone: 2, type: :rectangle)
File.write("rectangular.svg", DataMatrix.format(matrix, :svg, module_size: 8))
Example rectangular Data Matrix