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);
}
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");
}
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");
}
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");
}
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);
}
Aggregations