Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

A simle way to generate Datamatrix barcode using C#

aipsysaipsys Posts: 2Member

constants:
SymbolSize:

SymbolRectAuto = -2
SymbolSquareAuto=-1
Symbol10x10=0
Symbol12x12=1
Symbol14x14=2
Symbol16x16=3
Symbol18x18=4
Symbol20x20=5
Symbol22x22=6
Symbol24x24=7
Symbol26x26=8
Symbol32x32=9
Symbol36x36=10
Symbol40x40=11
Symbol44x44=12
Symbol48x48=13
Symbol52x52=14
Symbol64x64=15
Symbol72x72=16
Symbol80x80=17
Symbol88x88=18
Symbol96x96=19
Symbol104x104=20
Symbol120x120=21
Symbol132x132=22
Symbol144x144=23
Symbol8x18=24
Symbol8x32=25
Symbol12x26=26
Symbol12x36=27
Symbol16x36=28
Symbol16x48=29


Mode:

Ascii=0
C40=1
Text=2
X12=3
Edifact=4
Base256=5
AsciiGS1=6


Programming samples:

.........
using aipsys.datamatrix.encoder;
..........

Encode to Bitmap and show it:

ImageEncoder iee = new ImageEncoder();
ie.Margin = 4;
ie.PixelSize = 3;
ie.Scheme = 0;
ie.SymbolSize = -2;
string s = "http://www.aipsys.com";
pictureBox1.Image = iee.Encode2Image(s);

Encode and save the barcode image to file:

ImageEncoder ie = new ImageEncoder();
ie.Margin = 4;
ie.PixelSize = 3;
ie.Scheme = 0;
ie.SymbolSize = -2;
ie.Encode2ImageFile("http://www.aipsys.com", "c:\test.gif");


the SDK can be downloaded from http://www.aipsys.com

Comments

  • ThomassunshineThomassunshine Posts: 3Member
    The symbol size of Data Matrix ECC200 consists of even rows and even columns. Some symbols are square with sizes from 10*10 to 144*144; some symbols are rectangular with sizes from 8*18 to 16*48
    Here is a sample code of [link=http://www.businessrefinery.com/products/barcode_net/barcodes/net-data-matrix.html]create Data Matrix in .net[/link].
    using BusinessRefinery.Barcode;

    DataMatrix barcode = new DataMatrix();
    barcode.Code = "Data Matrix";
    barcode.Format = ImageFormat.Gif;
    barcode.drawBarcode2ImageFile("c:/data-matrix-csharp.gif");
  • abby321abby321 Posts: 8Member
    I have ever used the following codes to [link=http://www.barcodelib.com/csharp/barcode_symbologies/data_matrix.html]generate DataMatrix barcode[/link] image sucessfully. It's also very simple.
    BarcodeLib.Barcode.DataMatrix datamatrix = new BarcodeLib.Barcode.DataMatrix();
    datamatrix.Data = "1dfefg%^7fdsg56566";

    datamatrix.BackgroundColor = System.Drawing.Color.White;
    datamatrix.ModuleSize =6;
    datamatrix.RightMargin = 6;
    datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;


    // save barcode image into your system
    datamatrix.drawBarcode("c:/datamatrix.jpeg");

    // Encode datamatrix barcode & output to byte array
    byte[] barcodeInBytes = datamatrix.drawBarcodeAsBytes();

    // Encode datamatrix barcode to Graphics object
    Graphics graphics = ...;
    datamatrix.drawBarcode(graphics);

    // Encode datamatrix barcode and output to HttpResponse object
    HttpResponse response = ...;
    datamatrix drawBarcode(response);

    // Encode datamatrix barcode and output to Stream object
    Stream stream = ...;
    datamatrix drawBarcode(stream);
  • abby321abby321 Posts: 8Member
    I have ever used the following codes to [link=http://www.barcodelib.com/csharp/barcode_symbologies/data_matrix.html]generate DataMatrix barcode[/link] image sucessfully. It's also very simple.
    BarcodeLib.Barcode.DataMatrix datamatrix = new BarcodeLib.Barcode.DataMatrix();
    datamatrix.Data = "1dfefg%^7fdsg56566";

    datamatrix.BackgroundColor = System.Drawing.Color.White;
    datamatrix.ModuleSize =6;
    datamatrix.RightMargin = 6;
    datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;


    // save barcode image into your system
    datamatrix.drawBarcode("c:/datamatrix.jpeg");

    // Encode datamatrix barcode & output to byte array
    byte[] barcodeInBytes = datamatrix.drawBarcodeAsBytes();

    // Encode datamatrix barcode to Graphics object
    Graphics graphics = ...;
    datamatrix.drawBarcode(graphics);

    // Encode datamatrix barcode and output to HttpResponse object
    HttpResponse response = ...;
    datamatrix drawBarcode(response);

    // Encode datamatrix barcode and output to Stream object
    Stream stream = ...;
    datamatrix drawBarcode(stream);
  • SFSAFSSSFSAFSS Posts: 1Member
    Here is the sample Code I have used to [link=http://www.onbarcode.com/csharp/data-matrix-generator.html]create Data Matrix barcode in C#[/link]:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using OnBarcode.Barcode;
    using System.Drawing.Imaging;
    using System.Drawing;


    DataMatrix datamatrix = new DataMatrix();

    // Barcode data to encode
    datamatrix.Data = "OnBarcode";
    // Data Matrix data mode
    datamatrix.DataMode = DataMatrixDataMode.ASCII;
    // Data Matrix format mode
    datamatrix.FormatMode = DataMatrixFormatMode.Format_16X16;

    /*
    * Barcode Image Related Settings
    */
    // Unit of meature for all size related setting in the library.
    datamatrix.UOM = UnitOfMeasure.PIXEL;
    // Bar module size (X), default is 3 pixel;
    datamatrix.X = 3;
    // Barcode image left, right, top, bottom margins. Defaults are 0.
    datamatrix.LeftMargin = 0;
    datamatrix.RightMargin = 0;
    datamatrix.TopMargin = 0;
    datamatrix.BottomMargin = 0;
    // Image resolution in dpi, default is 72 dpi.
    datamatrix.Resolution = 72;
    // Created barcode orientation.
    //4 options are: facing left, facing right, facing bottom, and facing top
    datamatrix.Rotate = Rotate.Rotate0;

    // Generate data matrix and encode barcode to gif format
    datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;
    datamatrix.drawBarcode("C:\datamatrix.gif");

    /*
    You can also call other drawing methods to generate barcodes

    public void drawBarcode(Graphics graphics);

    public void drawBarcode(string filename);

    public Bitmap drawBarcode();

    public void drawBarcode(Stream stream);

    */
    The [link=http://www.onbarcode.com/tutorial/csharp-barcode-encoding-data.html]C# barcode data encoding guide[/link] is very helpful.
  • jacaboojacaboo Posts: 1Member
    i have several years' experience in generating barcode, i think some turioals and articles might be helpful. you can google data martrix barcode, and some articles can be available. i can give you some if you need .
    this is the [link=http://www.rasteredge.com/how-to/csharp-imaging/barcode-generating-datamatrix/]turoial of generating data martrix barcode[/link] , you can ,make it as reference and the tool if free for 30 days. this is the [link=http://www.rasteredge.com/how-to/csharp-imaging/barcode-generating/]barcode generator in c#[/link] and other formats, i think it might also be helpful

    good luck.


  • mariahsharpmariahsharp Posts: 43Member
    this is a such familiar question,for I've just solved this kind of question a month ago.this [link=http://www.keepautomation.com/csharp_barcode/data_matrix.html]data matrix in C#[/link] helped me. so you may have a try.
  • mariahsharpmariahsharp Posts: 43Member
Sign In or Register to comment.