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

Home > Java Barcode Generator > Barcode Generation Guide > Barcode Image Size Settings in Java Barcode Generator

Download Java Barcode

FAQ: Barcode Size Control in Java Barcode Generator

How to control barcode width & height in Java Barcode Generator




Barcode Size Settings in Java Barcode Generator

The generated barcode image includes 3 areas:

Drawing Area, Minimum Area, and Image Area.

  • Drawing Area: the area to draw barcode and barcode text

    Width: is decided by barcode module width (property X, and property X minimum is 1 pixel, and must be integer) * the number of barcode modules

    Height: is decided by barcode module height (property Y) and displaying text height

  • Minimum Area: some barcode types need minimum space around barcode (a.k.a quite zone). You can set the space through 4 properties, leftMargin, rightMargin, topMargin, bottomMargin.

    Width: leftMargin + Drawing Area Width + rightMargin

    Height: topMargin + Drawing Area Height + bottomMargin

  • Image Area: the generated barcode image area.

    Width: you can set barcode image area width through property barcodeWidth.

    However if your barcodeWidth is less than Minimum Area Width, barcode library will ignore this property (barcodeWidth) setting.

    Height: you can set barcode image area width through property barcodeHeight.

    However if your barcodeHeight is less than Minimum Area Height, barcode library will ignore this property (barcodeHeight) setting.



Java code to generate the above barcode image.
	Linear linear = new Linear();
        
        linear.setData("123456789");
        linear.setType(Linear.CODE39);
        linear.setUOM(Linear.UOM_PIXEL);

        linear.setX(1);
        linear.setY(80);

        linear.setLeftMargin(10);
        linear.setRightMargin(10);
        linear.setTopMargin(10);
        linear.setBottomMargin(10);

        linear.setBarcodeWidth(width);
        linear.setBarcodeHeight(height);
			
		








   Copyright © 2014 BarcodeLib.com. All rights reserved.