Search in sources :

Example 21 with BarCodeBuilder

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);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 22 with BarCodeBuilder

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);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) BufferedImage(java.awt.image.BufferedImage)

Example 23 with BarCodeBuilder

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");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 24 with BarCodeBuilder

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"));
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 25 with BarCodeBuilder

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);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

BarCodeBuilder (com.aspose.barcode.BarCodeBuilder)56 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)3 MarginsF (com.aspose.barcode.MarginsF)2 Font (java.awt.Font)2 Graphics (java.awt.Graphics)2 Image (java.awt.Image)2 Caption (com.aspose.barcode.Caption)1 EnableChecksum (com.aspose.barcode.EnableChecksum)1 Resolution (com.aspose.barcode.Resolution)1 BarCodeReader (com.aspose.barcode.barcoderecognition.BarCodeReader)1 MediaTracker (java.awt.MediaTracker)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1