Search in sources :

Example 1 with BarCodeBuilder

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

the class MyBarCode method paint.

public void paint(Graphics g) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(MyBarCode.class) + "BarcodeImage/RenderingFeatures/";
    String fileName = dataDir + "barcode.png";
    BarCodeBuilder bb = new BarCodeBuilder();
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    bb.setCodeText("12345678");
    bb.save(fileName);
    // Load and Draw the image on applet
    MediaTracker tr = new MediaTracker(this);
    File sourceimage = new File(fileName);
    Image image;
    try {
        image = ImageIO.read(sourceimage);
        tr.addImage(image, 0);
        g.drawImage(image, 0, 0, this);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : MediaTracker(java.awt.MediaTracker) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) IOException(java.io.IOException) Image(java.awt.Image) File(java.io.File)

Example 2 with BarCodeBuilder

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

the class CreateDatamatrixBarcode method createDataMatrixBarcodeWithC40Encoding.

public static void createDataMatrixBarcodeWithC40Encoding(String dataDir) {
    // Create an instance of BarCodeBuilder class
    // Set codetext value and EncodeType
    com.aspose.barcode.BarCodeBuilder buidler = new com.aspose.barcode.BarCodeBuilder("ABCDEF123456", com.aspose.barcode.EncodeTypes.DATA_MATRIX);
    // Set the DataMatrix encoding mode to C40
    buidler.setDataMatrixEncodeMode(com.aspose.barcode.DataMatrixEncodeMode.C40);
    // Save the barcode image
    buidler.save("dataMatrixC40.png");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 3 with BarCodeBuilder

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

the class CreatebarcodewithImageInsteadOfCodetext method main.

public static void main(String[] args) throws IOException {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(SetAztecSymbolMode.class) + "TwoD_barcodes/BasicFeatures/";
    // Create an instance of BarCodeBuilder class
    // Set the barcode text
    // Set the barcode symbology
    com.aspose.barcode.BarCodeBuilder builder = new com.aspose.barcode.BarCodeBuilder("123456789012", com.aspose.barcode.EncodeTypes.EAN_13);
    // Generate Barcode image and store it
    java.awt.image.BufferedImage barcode = builder.generateBarCodeImage();
    // Load the logo/other image from disk
    java.awt.image.BufferedImage picture = javax.imageio.ImageIO.read(new java.io.File("path_to_your_picture.png"));
    // Create a new empty image with new Calculated height & width
    java.awt.image.BufferedImage output = new java.awt.image.BufferedImage(Math.max(barcode.getWidth(), picture.getWidth()), barcode.getHeight() + picture.getHeight(), java.awt.image.BufferedImage.TYPE_INT_ARGB);
    // Get the Graphics object
    java.awt.Graphics g = output.getGraphics();
    // Set the canvas color
    g.setColor(java.awt.Color.WHITE);
    // Draw the primary image (barcode image) on the canvas
    g.drawImage(picture, 0, 0, null);
    // Draw the second image (logo image) on the canvas inside the barcode image
    g.drawImage(barcode, 0, picture.getHeight(), null);
    // Save the final barcode image
    java.io.File imageFile = new java.io.File("output.png");
    javax.imageio.ImageIO.write(output, "PNG", imageFile);
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 4 with BarCodeBuilder

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

the class CreatingAPdf417Barcode method createAPdf417Barcode.

public static void createAPdf417Barcode(String dataDir) {
    BarCodeBuilder b = new BarCodeBuilder();
    b.setEncodeType(com.aspose.barcode.EncodeTypes.PDF_417);
    b.setCodeText("1234567890");
    b.save(dataDir + "pdf417.bmp");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 5 with BarCodeBuilder

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

the class CreatingAQRBarcode method set_QR_version.

public static void set_QR_version(String dataDir) throws IOException {
    // Instantiate BarCodeBuilder object
    com.aspose.barcode.BarCodeBuilder builder = new com.aspose.barcode.BarCodeBuilder();
    // Set the Code text for the barcode
    builder.setCodeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    // Set the symbology type to QR
    builder.setEncodeType(com.aspose.barcode.EncodeTypes.QR);
    // Set the error level
    builder.setQRErrorLevel(com.aspose.barcode.QRErrorLevel.LevelQ);
    // Set the QR barcode version number
    builder.setQRVersion(com.aspose.barcode.QRVersion.VERSION_10);
    // Save the image
    builder.save(dataDir + "qr_version10_errorQ.png");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) 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