Java Barcode Generator, .NET Barcode Generator for C#, ASP.NET, VB.NET
HOME PURCHASE SITEMAP COMPANY

Home > Products > Java Barcode > Java Data Matrix Barcodes Generator

Download Java Barcode Trial

Java Data Matrix Generator, Generating Barcode Data Matrix in Java, Jasper, BIRT projects



It is also known as Data Matrix, ECC200.


Quick Navigate

 
1. Java Data Matrix Introduction
DataMatrix is a two-dimensional (2D) barcode symbology which can store from 1 to about 2,000 characters.
DataMatrix ECC200 version supports advanced encoding error checking and correction algorithms (reed-solomon). Those algorithms allow the recognition of barcodes that are up to 60% damaged.

DataMatrix is being used to encode product and serial number information on electrical rating plates; to mark of surgical instruments in Japan; to identify lenses, circuit boards, and other items during manufacturing.
Barcode Library supports all DataMatrix Formats and the data represented in the symbol can be compressed using one of following algorithms.
  • Auto (0): Barcode library will decide the best data mode for you.
  • ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127). This is the default encoding format by Barcode Library.
  • C40 (2): it is used to encode data that mainly contains numeric and upper case characters.
  • Text (3): it is used to encode data that mainly contains numeric and lower case characters.
  • X12 (4):it is used to encode the standard ANSI X12 electronic data interchange characters.
  • EDIFACT (5): it is used to encode 63 ASCII values (values from 32 to 94) plus an Unlatch character (binary 011111).
  • Base256 (6): it is used to encode 8 bit values.

Sample of a DataMatrix Barcode


 
2. Java Data Matrix Encoding Data Scope
Data Matrix Barcode for Java supports:
  • all 128 characters of ASCII
  • values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.


 
3. How to Generate Barcode Data Matrix Image in Standalone Java Applications?

The following code illustrates how to create a barcode in a Java class

1            DataMatrix barcode = new DataMatrix(); 
2            barcode.setData("123456789"); 
4            barcode.renderBarcode("c:/datamatrix.gif"); 


  • Create a DataMatrix object (line 1)
  • set DataMatrix object properties (line 2)
  • save into gif file (line 4)



 
4. How to Generate Barcode Data Matrix Image in Web Applications?

There are two ways to create barcode images in your Java web applications.

  1. This is the simplest way to stream barcode image using our provided barcode servlet classes.

    And it will not save barcode images in your server side.

    • Under demo package, copy barcode folder to your java servlet container like tomcat.

    • To test your installation, goto http://YourDomain:Port/barcode/datamatrix?Data=123456789

    • To create barcode image in your JSP or html page, you can pass the url to IMG tag src value. For example, <img src="http://YourDomain:Port/barcode/datamatrix?Data=123456789" />

  2. The second method is similar with the way to generate barcode in Java applications.

    • Create a barcode image in server side

      1            DataMatrix barcode = new DataMatrix(); 
      2            barcode.setData("123456789"); 
      4            barcode.renderBarcode("C:/Tools/Tomcat 5.5/webapps/YourWebApp/bimages/datamatrix.gif"); 
      
      
      

    • In your JSP page, you can using IMG tag to display generated image, like <img src="http://YourDomain:Port/YourWebApp/bimages/datamatrix.gif" />



 
5. How to Generate Barcode Data Matrix Image in JasperReports?

The following jasper xml content illustrates how to insert a barcode into JasperReports

<import value="com.barcodelib.barcode.BarcodeJasperFactory"/> 

Import class BarcodeJasperFactory to report.

<image scaleImage="Clip" hAlign="Center"> 
    <reportElement x="50" y="110" width="515" height="120"/> 
    <graphicElement/> 
    <imageExpression class="net.sf.jasperreports.engine.JRRenderable">
<![CDATA[new com.barcodelib.barcode.BarcodeJasperRenderer(BarcodeJasperFactory.createDataMatrix("123456789", 0, 0))]]></imageExpression> </image>

Please go to class BarcodeJasperFactory in Java doc for all methods to create barcode.

Developers can also extend or modify BarcodeJasperFactory class to meet their own requirements. Complete BarcodeJasperFactory.java Source Code



 
6. How to Generate Barcode Data Matrix Image in Eclipse BIRT?

Our Java barcode library supports generating barcode image in Eclipse BIRT framework.

Click here to view the details.



 
7. How to Save Barcode Data Matrix Image?
Just call DataMatrix object method renderBarcode, e.g. barcode.renderBarcode("c:/datamatrix.gif");


 
8. Java Data Matrix Property Settings
  • Set the data property with the value to encode. Type is String.
    Servlet Parameter: "Data".
  • Set the dataMode property.
    Valid value is DataMatrix.MODE_AUTO (default), DataMatrix.MODE_ASCII, DataMatrix.MODE_C40,
    DataMatrix.MODE_TEXT, DataMatrix.MODE_X12, DataMatrix.MODE_EDIFACT, DataMatrix.MODE_BASE256.
    • Auto (0): Barcode library will decide the best data mode for you.
    • ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127). This is the default encoding format by Barcode Library.
    • C40 (2): it is used to encode data that mainly contains numeric and upper case characters.
    • Text (3): it is used to encode data that mainly contains numeric and lower case characters.
    • X12 (4):it is used to encode the standard ANSI X12 electronic data interchange characters.
    • EDIFACT (5): it is used to encode 63 ASCII values (values from 32 to 94) plus an Unlatch character (binary 011111).
    • Base256 (6): it is used to encode 8 bit values.

    Servlet Parameter: "DataMode".
  • Set the format property. Type is int. Default is DataMatrix.FORMAT_10X10. Specifies the Data Matrix Format to use on that symbology.
    Valid values see class DataMatrix.FORMAT_*x*;
    Servlet Parameter: "Format".
  • Data Matrix can be divided into multiple data areas. Conversely, information stored in multiple Data Matrix symbols can be reconstructed as single data symbols. One data symbol can be divided into up to 16 symbols.
    • Set isStructuredAppend property to true, then Structured Append is enabled.
      Servlet Parameter: "IsStructuredAppend".
    • Set symbolCount property to the number of total symbols which make the sequence.
      Servlet Parameter: "SymbolCount".
    • Set symbolIndex property to the position of current symbol in the secuence (Start with 0).
      Servlet Parameter: "SymbolIndex".
    • Set fileID property to be identified to the same file.
      Servlet Parameter: "FileID".
  • Set the FNC1Mode property.
    • DataMatrix.FNC1_NONE (0)
    • DataMatrix.FNC1_ENABLE (1)

    Servlet Parameter: "FNC1Mode".
  • Set the applicationIndicator property. Please set this property, if property FNC1Mode value is DataMatrix.FNC1_ENABLE (1).
    Servlet Parameter: "ApplicationIndicator".
  • Setting up barcode image size:
    • Set property uom (Unit of Measure) for properties moduleSize, leftMargin, rightMargin, topMargin and bottomMargin.
      Default is DataMatrix.UOM_PIXEL (0). Valid values are DataMatrix.UOM_PIXEL (0), DataMatrix.UOM_CM (1), DataMatrix.UOM_Inch (2).
      Servlet Parameter: "UOM".
    • Set the moduleSize (for bar cell width and height). Type is float. Default is 5.
      Servlet Parameter: "ModuleSize".
    • Set the leftMargin, rightMargin, topMargin and bottomMargin properties.
      Types are all float. Default are 5 * moduleSize.
      Servlet Parameter: "LeftMargin", "RightMargin", "TopMargin", "BottomMargin".
    • Set the barcodeWidth (barcode image width) and barcodeHeight (barcode image height) properties. Both types are float.
      Servlet Parameter: "BarcodeWidth", "BarcodeHeight".
    • Set the resolution property (Value is expressed in DPI - Dots per inch).
      Servlet Parameter: "Resolution".
  • Set rotate property, if you want to rotate barcode image.
    Value can be
    0 (DataMatrix.ANGLE_0),
    1 (DataMatrix.ANGLE_90),
    2 (DataMatrix.ANGLE_180),
    3 (DataMatrix.ANGLE_270)
    Servlet Parameter: "Rotate".
  • Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is false.
    • ~3: is used only at the very beginning of the symbol for the reader programming purpose.
    • ~5: is used only at the very beginning of the symbol, the header [)> + ASCII 30 + ASCII 05 + ASCII 29 will be transmitted by the barcode reader before the data in the message and the trailer ASCII 30 + ASCII 4 will be transmitted afterwards.
    • ~6: is used only at the very beginning of the symbol, the header [)> + ASCII 30 + ASCII 06 + ASCII 29 will be transmitted by the barcode reader before the data in the message and the trailer ASCII 30 + ASCII 4 will be transmitted afterwards.
    • ~7NNNNNN: is used to specify the Extended Channel Interpretations and NNNNNN is a value between 000000 and 999999.
    • ~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 to 255

    Servlet Parameter: "ProcessTilde".


 
9. How to Set Generated Barcode Data Matrix Image Size?

To set barcode image width and height, there are two ways to do it.

1) You can set barcode image width and height through properties barcodeWidth and barcodeHeight values, barcode library will render the barcode image for you.

or

2) You can set moduleSize value (barcode module width and height value), barcode library will calculate the barcodeWidth and barcodeHeight values for you, and render the barcode image.





All Java Barcode Types/Symbologies


 









   Copyright 2010 BarcodeLib.com. Java Barcode, Barcode Java, Java Barcode Generator. All rights reserved.