Search in sources :

Example 26 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class GenerateMultipleBarcodesOnASingleImage method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(GenerateMultipleBarcodesOnASingleImage.class) + "BarcodeReader/advanced_features/";
    HashMap collection = new HashMap();
    collection.put("ONE123", com.aspose.barcode.EncodeTypes.CODE_39_STANDARD);
    collection.put("Process Collection", com.aspose.barcode.EncodeTypes.DATA_MATRIX);
    collection.put("Dictionary Collection", com.aspose.barcode.EncodeTypes.QR);
    collection.put("X06712AT", com.aspose.barcode.EncodeTypes.CODE_128);
    collection.put("979026000043", com.aspose.barcode.EncodeTypes.EAN_13);
    collection.put("Aztec BarCode", com.aspose.barcode.EncodeTypes.AZTEC);
    ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
    for (Object key : collection.keySet()) {
        BarCodeBuilder bb = new BarCodeBuilder();
        bb.setCodeText((String) key);
        // bb.setSymbologyType((Long) collection.get(key));
        images.add(bb.generateBarCodeImage());
    }
    int maxWidth = 0;
    int sumHeight = 0;
    for (BufferedImage bmp : images) {
        sumHeight += bmp.getHeight();
        if (maxWidth < bmp.getWidth())
            maxWidth = bmp.getWidth();
    }
    int offset = 10;
    BufferedImage resultBitmap = new BufferedImage(maxWidth + offset * 2, sumHeight + offset * images.size(), BufferedImage.TYPE_INT_ARGB);
    Graphics g = resultBitmap.getGraphics();
    g.setColor(Color.white);
    // g.drawRect(0, 0, width, height);
    g.fillRect(0, 0, resultBitmap.getWidth(), resultBitmap.getHeight());
    int yPosition = offset;
    for (int i = 0; i < images.size(); ++i) {
        BufferedImage currentBitmap = images.get(i);
        g.drawImage(currentBitmap, offset, yPosition, null);
        yPosition += currentBitmap.getHeight() + offset;
    }
    File outputfile = new File(dataDir + "output.png");
    ImageIO.write(resultBitmap, "png", outputfile);
}
Also used : Graphics(java.awt.Graphics) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Example 27 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CodeTextForegroundColor method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(CodeTextForegroundColor.class) + "Barcode/BasicFeatures/";
    // Instantiate Barcode object
    BarCodeBuilder bb = new BarCodeBuilder();
    // Set up code text (data to be encoded)
    bb.setCodeText("1234567");
    // Set up code text color
    bb.setCodeTextColor(Color.RED);
    // Save the Barcode image to file
    bb.save(dataDir + "codeTextForegroundColor.jpg");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 28 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class BarcodeImageQuality method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(BarcodeImageQuality.class) + "BarcodeImage/BasicFeatures/";
    BarCodeBuilder bb = new BarCodeBuilder();
    bb.setCodeText("1234567");
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    // Set the graphics drawing hint to be Anti Alias
    bb.setImageQuality(ImageQualityMode.AntiAlias);
    // Save the image
    bb.save(dataDir + "barcode-image-quality.jpg");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 29 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreateDatamatrixBarcode method encodeModeForDataMatrix.

public static void encodeModeForDataMatrix(String dataDir) {
    BarCodeBuilder objBuilder = new BarCodeBuilder();
    objBuilder.setEncodeType(com.aspose.barcode.EncodeTypes.DATA_MATRIX);
    objBuilder.setDataMatrixEncodeMode(DataMatrixEncodeMode.ASCII);
    objBuilder.setCodeText("This is the data to be encoded");
    objBuilder.save(dataDir + "encodeModeForDataMatrix.bmp");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 30 with BarCodeBuilder

use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.

the class CreateDatamatrixBarcode method customEncodingModeForDataMatrix.

public static void customEncodingModeForDataMatrix(String dataDir) throws IOException {
    BarCodeBuilder objBuilder = new BarCodeBuilder();
    objBuilder.setEncodeType(com.aspose.barcode.EncodeTypes.DATA_MATRIX);
    objBuilder.setDataMatrixEncodeMode(DataMatrixEncodeMode.Custom);
    objBuilder.setCodeTextEncoding(Charset.forName("UTF-8"));
    objBuilder.setCodeText("öäüéà �?");
    objBuilder.save(dataDir + "output_Utf8.bmp", BarCodeImageFormat.Bmp);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

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