datamatrix是二维的条形码,它是由黑色和白色的单元格构成,这些单元格分布于一个正方形或者矩形的模型中。它可以存储文本信息和数字信息。
下面的例子将展示如何用spire.barcode for .net生成一个datamatrix条形码。
c#
//生成barcodesettings实例
barcodesettings settings = new barcodesettings();
//设置条形码类型为datamatrix
settings.type = barcodetype.datamatrix;
//设置条形码模型宽度
settings.x = 1.5f;
//设置datamatrix模型为正方形
settings.datamatrixsymbolshape = datamatrixsymbolshape.square;
//设置datamatrix模型为矩形
//settings.datamatrixsymbolshape = datamatrixsymbolshape.rectangle;
//设置数据和显示文本
settings.data = "abc 123456789abc 123456789abc 123456789";
settings.data2d = "abc 123456789abc 123456789abc 123456789";
//生成datamatrix条形码并保存为png格式的图片
barcodegenerator generator = new barcodegenerator(settings);
image image = generator.generateimage();
image.save("datamatrix.png", system.drawing.imaging.imageformat.png);
vb.net
'生成barcodesettings实例
dim settings as new barcodesettings()
'设置条形码类型为datamatrix
settings.type = barcodetype.datamatrix
'设置条形码模型宽度
settings.x = 1.5f
'设置datamatrix模型为正方形
settings.datamatrixsymbolshape = datamatrixsymbolshape.square
'设置datamatrix模型为矩形
'settings.datamatrixsymbolshape = datamatrixsymbolshape.rectangle;
'设置数据和显示文本
settings.data = "abc 123456789abc 123456789abc 123456789"
settings.data2d = "abc 123456789abc 123456789abc 123456789"
'生成datamatrix条形码并保存为png格式的图片
dim generator as new barcodegenerator(settings)
dim image as image = generator.generateimage()
image.save("datamatrix.png", system.drawing.imaging.imageformat.png)
正方形:
矩形: