Java UPC-A Generator Image Setting Tutorial
sample source code to generate UPC-A in png, jpeg, etc. image formats in Java
- Common-used image formats are valid here, which are png, tiff, gif, jpeg and bmp
- UPC-A barcode can be set in the center, right or left of the image
- UPC-A image color can be changed with setting BackColor, ForeColor and TextColor
- The generated UPC-A image resolution can be set to be a fixed value with your need
- Java UPC-A generation component supports rotating UPC-A image with 0, 90, 180, 270 angles
- Developer Guide is written and included in Java barcode creator trial package to generate barcode in your Java program easily
- Complete Library Source code for Java Barcode is provided with purchase of Unlimited Developer License with Source Code
- Draw high-quality UPC-A barcodes in Java Class, J2SE applications by setting the size of barcode
- Supports Java Reports software to set your wanted size of UPC-A
- Generate and print UPC-A in JDK 1.4.0 and later version
UPC-A, also known as Universal Product Code version A , UPC Code, UPC Symbol, GTIN-12, GS1-12, UCC-12, is the most common and well-known barcode symbology in the United States.
Excludig Java UPC-A image setting page for UPC-A image setting details, there are other pages for linear barcode - UPC-A size setting and data setting in Java development.
Navigate to Linear barcode - UPC-A Size Setting for Java to change the UPC-A size such as bar widht, image width, supplement data
Navigate to Linear barcode - UPC-A Data Encoding for Java to set UPC-A valid data with supplement data in proper length.
Java UPC-A Image Setting Properties and Sample Code
Linear barcode UPC-A image can contains two parts which the main UPC-A image and the supplement barcode image near the UPC-A. All of the image setting parameters requires installing and setup the UPC-A linear barcode object in Java application at first.
UPCA barcode = new UPCA();
//UPC-A in Java can only encode 11 numeric data in the data to set excluding check sum.
barcode.setData("55555666666");
Supplement Barcode for UPC-A image Setting
UPC-A image supplement barcode for UPC-A image setting needs setting the supplement data with 2 or 5 digits at first, then setting the supplement data supplement space and supplement height
barcode.setsupData("12");
//adjust the height of supplement barcode,default is 0.8f.
barcode.setsupHeight(3);
//Adjust the width between the main barcode and the supplement barcode. default is 15.
barcode.setsupSpace(20);
Common Related Image Settings for Java UPC-A Image
- resolution: UPC-A barcode image resolution in DPI (Dots per inch), default is 72;
- rotate: show the UPC-A generated in Java with 0, 90, 180, 270 angles b y rotating it, default is 0 (IBarcode.ROTATE_0); Valid choices are 0 (IBarcode.ROTATE_0); 1 (IBarcode.ROTATE_90); 2 (IBarcode.ROTATE_180); 3 (IBarcode.ROTATE_270);
- backColor: Java UPC-A image background color, default is white;
- foreColor: Java UPC-A fore ground color, which actually is the bar color, default is black;
- barAlignment: Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right; default is 1: center.
- textColor: the color of the text printed below the barcode image
Sample code for each of the above parameters and you just need to copy one(s) and replace it to be the target valid one:
barcode.setResolution(100);
barcode.setRotate(IBarcode.ROTATE_180);
barcode.setbackColor(red);
barcode.setforeColor(black);
barcode.setbarAlignment(0(left));
barcode.settextColor(black);
Show text for Java UPC-A
UPC-A generator in Java show text can be enable or disable with your need.
barcode.setshoeText(false);
Note that if you set show text to be false, all the text concerned proerties such as text margin, text color, text font are invalid with the generated UPC-A iamge showing without text.
Java UPC-A Image Format Setting
Java UPC-A generation control supports generating high quality UPC-A image with common used image formats like png, tiff, gif, jpeg and bmp. A sample code is below for your easier implementation with just copying and changing to the target format.
barcode.drawBarcode("C:\\UPC-A.tiff");