use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class CreateDatamatrixBarcode method createADataMatrixBarcode.
public static void createADataMatrixBarcode(String dataDir) throws IOException {
BarCodeBuilder objBuilder = new BarCodeBuilder();
objBuilder.setEncodeType(com.aspose.barcode.EncodeTypes.DATA_MATRIX);
objBuilder.setCodeText("1234567890");
objBuilder.save(dataDir + "datamatrix.bmp");
objBuilder.save(dataDir + "datamatrix.emf", com.aspose.barcode.BarCodeImageFormat.Emf);
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class CreatingAPdf417Barcode method pdf417ErrorCorrectionLevel.
public static void pdf417ErrorCorrectionLevel(String dataDir) {
BarCodeBuilder b = new BarCodeBuilder();
b.setEncodeType(com.aspose.barcode.EncodeTypes.PDF_417);
b.setPdf417ErrorLevel(Pdf417ErrorLevel.Level8);
b.setCodeText("12345");
b.save(dataDir + "pdf417ErrorCorrectionLevel.bmp");
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class CreatingAPdf417Barcode method pdf417CompactionMode.
public static void pdf417CompactionMode(String dataDir) {
BarCodeBuilder builder = new BarCodeBuilder("This is text data", com.aspose.barcode.EncodeTypes.PDF_417);
// Set Pdf417 Compaction Mode to Text
builder.setPdf417CompactionMode(Pdf417CompactionMode.Text);
// Save the image to disk in PNG format
builder.save(dataDir + "pdf417CompactionMode.png");
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class CreatingAQRBarcode method QRBarcodeWithImage.
public static void QRBarcodeWithImage(String dataDir) throws IOException {
// Define barcode image height & width
int QRCODE_IMAGE_HEIGHT = 300;
int QRCODE_IMAGE_WIDTH = 300;
// Create an instance of BarCodeBuilder class
// Set the barcode text
// Set the barcode symbology
BarCodeBuilder builder = new BarCodeBuilder("123456789", com.aspose.barcode.EncodeTypes.QR);
// Set the error level
builder.setQRErrorLevel(com.aspose.barcode.QRErrorLevel.LevelH);
// Set the Graphics Unit
builder.setGraphicsUnit(2);
// Generate the barocde image and save it as image in an object of BufferedImage class
java.awt.image.BufferedImage image = builder.getCustomSizeBarCodeImage(QRCODE_IMAGE_WIDTH, QRCODE_IMAGE_HEIGHT, false);
System.out.println("ImageHeight: " + image.getHeight());
// Load the image in an object of BufferedImage class - this is the image that you want to embed into the barcode image.
java.awt.image.BufferedImage overlay = javax.imageio.ImageIO.read(new java.io.File("wifi_logo.jpg"));
// Calculate the height & width
int deltaHeight = image.getHeight() - overlay.getHeight();
int deltaWidth = image.getWidth() - overlay.getWidth();
// Create a new empty image
java.awt.image.BufferedImage combined = new java.awt.image.BufferedImage(QRCODE_IMAGE_WIDTH, QRCODE_IMAGE_HEIGHT, java.awt.image.BufferedImage.TYPE_INT_ARGB);
// Get the Graphics2D object
java.awt.Graphics2D g = (java.awt.Graphics2D) combined.getGraphics();
// Draw the primary image (barcode image) on the canvas
g.drawImage(image, 0, 0, null);
g.setComposite(java.awt.AlphaComposite.getInstance(java.awt.AlphaComposite.SRC_OVER, 1f));
// Draw the second image (logo image) on the canvas inside the barcode image
g.drawImage(overlay, (int) Math.round(deltaWidth / 2), (int) Math.round(deltaHeight / 2), null);
// Create and save the final very of the image with barcode and logo inside it
java.io.File imageFile = new java.io.File("qrcode_with_logo.png");
javax.imageio.ImageIO.write(combined, "PNG", imageFile);
}
use of com.aspose.barcode.BarCodeBuilder in project Aspose.BarCode-for-Java by aspose-barcode.
the class CreatingAQRBarcode method rotation.
public static void rotation(String dataDir) throws IOException {
BarCodeBuilder b = new BarCodeBuilder();
b.setEncodeType(com.aspose.barcode.EncodeTypes.QR);
b.setCodeText("1234567890");
// Hide code text
b.setCodeLocation(CodeLocation.None);
b.setRotationAngleF(90);
b.save(dataDir + "rotation_qr.bmp", BarCodeImageFormat.Bmp);
}
Aggregations