Java Classes: barcode
Version : 2.0.3
Licence : GPL / Cecill
Date : 2013-01-06
Author: HOUREZ Jonathan, DEMONTE Jean-Baptiste
Download Java Barcode 2.0.3
Installing Java classes Barcode
There are several options for installing Java classes: place the compiled files or JAR to the project root or in a folder accessible via the CLASSPATH. To use them, you must import via the command:
import com.barcode_coder.java_barcode.*;
It will define the classes of barcodes:
- Barcode11
- Barcode128
- Barcode2of5
- Barcode39
- Barcode93
- BarcodeCodabar
- BarcodeDatamatrix
- BarcodeEAN
- BarcodeMSI
To these are added the following classes:
- Bar
- Barcode
- Barcode1D
- BarcodeFactory
- BarcodeType
Using the Java Barcode
To use these classes, a factory was set up with two static methods for creating barcodes.
public static Barcode createBarcode(BarcodeType barcodeType, String code) public static Barcode createBarcode(BarcodeType barcodeType, String code, boolean crc)
barcodeType
BarcodeType
Le type de code-barres souhaité.
Valeurs possibles :
- BarcodeType.Codabar
- BarcodeType.Code11
- BarcodeType.Code39
- BarcodeType.Code93
- BarcodeType.Code128
- BarcodeType.EAN8
- BarcodeType.EAN13
- BarcodeType.Standard2of5
- BarcodeType.Interleaved2of5
- BarcodeType.MSI
- BarcodeType.Datamatrix
code
String
Barcode value (dependent on the type of barcode).
crc
boolean
Presence correcting code required or not
<< Return >>
Both methods return a Barcode.
Then the class Barcode provides, among other, a function to export barcode into image format desired.
public boolean export(String res, int width, int height, boolean hri, String file)
res
String
Image type : "png", "jpg" or "gif"
width, height
int
Width and height of a module. For 2D barcodes (Datamatrix), height will be set from width.
hri
boolean
display text (HRI : Human readable Interpretation).
file
String
The location where the image should be saved.
<< Return >>
Returns a boolean indicating if the export is successful or not.
Example 1 :
Barcode b = BarcodeFactory.createBarcode(BarcodeType.Code128,"12345678"); b.export("png",1,50,true,"/Users/name/Desktop/image.png");
Example 2 :
Barcode b = BarcodeFactory.createBarcode(BarcodeType.Datamatrix,"barcode-coder"); b.export("jpg",10,50,true,"/Users/name/Desktop/image.jpg");