use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class GenerateBarcodeWithEmptyBars method main.
public static void main(String[] args) throws IOException {
// The path to the resource directory.
String dataDir = Utils.getDataDir(GenerateBarcodeWithEmptyBars.class) + "BarcodeImage/BasicFeatures/";
// Create an instance of BarCodeBuilder and initialize it with CodeText and Symbology
BarCodeBuilder builder = new BarCodeBuilder("TEXT", com.aspose.barcode.EncodeTypes.CODE_128);
// Set the FilledBars property to false
builder.setFilledBars(false);
// Save the resultant barcode image on disk
builder.save(dataDir + "barcodeWithEmptyBars.png", BarCodeImageFormat.Png);
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class RenderBarCode method paint.
public void paint(Graphics g) {
BarCodeBuilder bb = new BarCodeBuilder();
bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
bb.setCodeText("12345678");
BufferedImage bimg = (BufferedImage) bb.generateBarCodeImage();
int w = bimg.getWidth();
int h = bimg.getHeight();
int[] rgb = new int[w * h];
bimg.getRGB(0, 0, w, h, rgb, 0, w);
if (rgb.length > 0) {
System.out.println("RGB OK.");
}
g.drawImage(bimg, 0, 0, this);
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class BarcodeCustomSize method main.
public static void main(String[] args) {
// The path to the resource directory.
String dataDir = Utils.getDataDir(BarcodeCustomSize.class) + "BarcodeImage/UtilityFeatures/";
// Instantiate barcode object
BarCodeBuilder builder = new BarCodeBuilder();
// Set the Code text for the barcode
builder.setCodeText("1234567890");
// Set the symbology type to Code39Standard
builder.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_39_STANDARD);
// Set auto size false
builder.setAutoSize(false);
// Set height
builder.setImageHeight(50);
// Set width
builder.setImageWidth(120);
// Save the image
builder.save(dataDir + "barcode-custom-size.jpg");
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class GetMinimumBarCodeSize method main.
public static void main(String[] args) throws IOException {
// The path to the resource directory.
String dataDir = Utils.getDataDir(BarcodeCustomSize.class) + "BarcodeImage/UtilityFeatures/";
// Create an instance of BarCodeBuilder class
// Set barcode text
// Set encoding type
com.aspose.barcode.BarCodeBuilder builder = new com.aspose.barcode.BarCodeBuilder("1234567890", com.aspose.barcode.EncodeTypes.CODE_128);
// Set graphic unit
builder.setGraphicsUnit(com.aspose.barcode.GraphicsUnit.Pixel);
// Call GetMinimumBarCodeSize method to get the minimum size required
java.awt.geom.Dimension2D minSize = builder.getMinimumBarCodeSize();
// Set Auto size to false
builder.setAutoSize(false);
// Set image height & width with the help of min size got from GetMinimumBarCodeSize method
builder.setImageWidth((float) minSize.getWidth());
builder.setImageHeight((float) minSize.getHeight());
// Save the barcode image
javax.imageio.ImageIO.write(builder.getBarCodeImage(), "PNG", new java.io.File("minimumresult.png"));
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class SaveBarcodeImageToStreams method main.
public static void main(String[] args) throws IOException {
BarCodeBuilder builder = new BarCodeBuilder();
builder.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
builder.setCodeText("123456");
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
builder.save(outStream, BarCodeImageFormat.Jpeg);
}
Aggregations