Java Code 128 Generator Size Setting Tutorial
sample source code to generate linear Code 128 images and adjust barcode size in Java
- Permanent license with the purchase of the developer license
- Generate barcodes which can be added to Oracle Reports and Crystal Reports
- Easy encapsulation, integration and customization are supported with JavaBean conforming to a particular convention under a developmental environment
- Class library contains all necessary class files for java barcode generation
- Supports Java Reports software to set your wanted size of Code 128
- Generate and print Code 128 in JDK 1.4.0 and later version
- Easy to Integrate Code 128 Generator other properties in your Java applications
- Unit of Measure can set the generated Code 128 image in Inch, CM or Pixel
- Text margin, text font can influence the size of Code 128 in Java
- Code 128 barcode can be set in the center, right or left of the image
- Code 128 image color can be changed with setting BackColor, ForeColor and TextColor
Code 128, also known as ANSI/AIM 128, ANSI/AIM Code 128, USS Code 128, Uniform Symbology Specification Code 128, is a very capable linear barcode of excellent density, high reliability.
Java Code 128 image setting provides specific details on how to change the image of the Code 128 generated in Java;
Java Code 128 data encoding provides specific details on how to set the Code 128 valid character set with valid character set.
Code 128 in Java Size Related Properties
Code 128 Character Set for Code 128 Generation in Java
Java Code 128 Generator supports four sets of Code 128 character to meet your any possible data encoding during the procedure of drawing Code 128 image
- 0 (SET_AUTO) - All ASCII 128 data(0-9, A-Z, a-z, special characters)
- 1 (SET_A) - ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters, and FNC 1-4
- 2 (SET_B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters, and FNC 1-4
- 3 (SET_C) - 00-99 (encodes each two digits with one code) and FNC1
Code 128 Width Related Settings in Java
- X: Width of Code 128 bar module (narrow bar), default is 1 pixel.
- barcodeWidth: Generated Code 128 barcode image width.
- leftMargin: Code 128 image left margin size.
- rightMargin: Code 128 image right margin size.
Code 128 Height Related Settings in Java
- Y: Height of Code 128 bar module, default is 30 pixel.
- barcodeHeight: Generated Code 128 barcode image height.
- topMargin: Code 128 image top margin size.
- bottomMargin: Code 128 image bottom margin size.
Other Code 128 Size Setting Properties in Java
- autoResize: Auto resize the generated Code 128 barcode image.
- uom: Unit of meature for all size related settings in the Java barcode library. Valid values: 0: pixel; 1: inch; 2: cm.
- textMargin: Space between barcode and printed barcode data, default is 6 pixel.
- textFont: Code 128 text (printed below barcode) font style.
Detailed Sample Code for Adjustment of Code 128 Size Setting Properties in Java Projects
Build Code 128 Object in Java
The first step for adjusting the Code 128 created by Java is to install and set up Code 128 generation SDK in the Java application, and build Code 128 object for more settings.
Code128 barcode = new Code128();
barcode.setData("Code 128 in Java");
Set Code 128 Character Set to Set Code 128 in Javae
Set Code 128 Uom to Set the Unit of Code 128 Measure
//valid choices are Pixel, Inch, CM
Set X, barcodeWidth, leftMargin and rightMargin to Set the Width of Code 128 with Java
During setting the Code 128 width with the above properties, you need to pay attention that after you set a fixed bar width (X), an auto barcode width - minimum barcode width will be set in Java applications. However, if the set barcodeWidth value is less than the minimum barcode width, the created Code 128 image width in Java will be the minimum value. If the set barcodeWith is larger than the minimum one, the extra width will be added on the right and left margins in Java.
Set Y, barcodeHeight, topMargin and bottomMargin to set the height of Code 128 using Java
During setting the Code 128 height with the above properties, you need to pay attention that after you set a fixed bar height (Y), an auto barcode height - minimum barcode height will be set in Java applications. However, if the set barcodeHeight value is less than the minimum barcode height, the created Code 128 image height in Java will be the minimum value. If the set barcodeHeight is larger than the minimum one, the extra width will be added on the top and bottom margins in Java.
Set textMargin and textFont in Java Code 128
//Before adjusting the Code 128 text, the first step is to set the show text to be true for adjustment in Java
barcode.setTextFont(new Font("Arial", 0, 12));