Java Data Matrix Generator Size Setting Tutorial

sample source code to generate 2D Data Matrix images and adjust barcode size in Java


  • Easy encapsulation, integration and customization are supported with JavaBean conforming to a particular convention under a developmental environment
  • Mature & Reliable Java Data Matrix generation library with latest barcode symbology ISO Standards
  • Provide professional features to set inter-character space and wide narrow bar ratio for Data Matrix
  • Completely developed in Java for any operating systems with Java Virtual Machine
  • Pre-configured industry standards Data Matrix allow any untrained users to insert Data Matrix in Java
  • Java Server Side projects (JSP, Servlet, EJB, J2EE, Web Service) can be easily integrated
  • Data Matrix image width in Java can be changed with Y (bar height), barcodeHeight, topMargin and bottomMargin
  • High quality Data Matrix images may be printed with any printers, including those low resolution printers
  • Common-used image formats are valid here, which are png, tiff, gif, jpeg and bmp
  • Encoding Data Matrix valid data set to generate valid Data Matrix images in Java applications

Data Matrix, also known as Data Matrix ECC200, is great 2-dimensional matrix barcode to store different data up to 2,335 alphanumeric characters.

Java Data Matrix generator provides other setting pages for more detailed information on how to generate and create high qulaity 2D Data Matrix barcode images in Java programming.

Java Data Matrix image setting concentrates on setting Data Matrix image color, resolution, rotation, bar lignment and so on;

Java Data Matrix data encoding concentrates on setting Data Matrix data encoding and valid data length in Java projects.


Properties to change the Size of Data Matrix in Java

Overall Properties to Influence Data Matrix Size in Java

  • uom: Unit of meature for all size related settings in the Java barcode library. Valid values: 0: pixel; 1: inch; 2: cm.
  • formatMode: Java Data Matrix module format.
  • X: value of Data Matrix module width and height, default is 3 pixel.

Data Matrix Width Related Settings in Java

  • barcodeWidth: Generated Data Matrix barcode image width, default is 0 pixel.
  • leftMargin: Data Matrix image left margin size, default is 0.
  • rightMargin: Data Matrix image right margin size, default is 0.

Data Matrix Height Related Settings in Java

  • barcodeHeight: Generated Data Matrix barcode image height, default is 0.
  • topMargin: Java Data Matrix image top margin size, default is 0.
  • bottomMargin: Java Data Matrix image bottom margin size, default is 0 pixel.

AutoResize for Data Matrix Size in Java

  • autoResize: Auto resize the generated Data Matrix barcode image in Java, especially setting the width and height


More Specific Guide on How to Adjust the Data Matrix Size

      //Set a Data Matrix object in Java applications
      DataMatrix barcode = new DataMatrix();
barcode.setData("Java-Data-Matrix");

Then, modify the following properties you may need:

Set Format Mode to change the Data Matrix size in Java

If format mode you set is conflict with the encoding data you set, the library can automatically set the proper mode in Java

      barcode.setFormatMode(DataMatrix.F_13X13);

Adjust Unit of Measure of Java Data Matrix

      barcode.setUom(IBarcode.UOM_CM);

Adjust X in Java Data Matrix

As a 2D barcode in Java, Java Data Matrix is obviously the bar module width and height is the same. For this reason, when ajusting the X, it will change the size of the module with changing the height and width at the same time in Java applicaions

      barcode.setX(3f);

Adjust the Width of Data Matrix with Java

      barcode.setLeftMargin(2f);
barcode.setRightMargin(2f);

Adjust the height of Data Matrix using Java

      barcode.setTopMargin(0f);
barcode.setBottomMargin(0f);




OnBarcode is a market-leading provider of barcode generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides high quality tutorials and guides for various linear, 2d barcode information, such as C# Barcode, QR Code C#, QR Code VB.NET, QR Code ASP.NET, QR Code .NET, ASP.NET Barcode. OnBarcode barcode products are supported by RasterEdge .NET HTML5 Document Viewer high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.