Search in sources :

Example 51 with BarCodeBuilder

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

the class BarcodeImageMargins method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(BarcodeImageMargins.class) + "BarcodeImage/BasicFeatures/";
    BarCodeBuilder bb = new BarCodeBuilder();
    bb.setCodeText("1234567");
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    bb.getMargins().setLeft(2f);
    bb.getMargins().setRight(2f);
    bb.getMargins().setTop(2f);
    bb.getMargins().setBottom(2f);
    // Save the image
    bb.save(dataDir + "barcode-image-margins.jpg");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 52 with BarCodeBuilder

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

the class RotateBarcodeImage method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(RotateBarcodeImage.class) + "BarcodeImage/BasicFeatures/";
    BarCodeBuilder bb = new BarCodeBuilder();
    bb.setCodeText("1234567");
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_39_EXTENDED);
    // Rotate clockwise for 180 degree (upside down)
    bb.setRotationAngleF(180);
    // Save the image
    bb.save(dataDir + "barcode-image-rotate.jpg");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder)

Example 53 with BarCodeBuilder

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

the class RenderBarcodeToImageInstance method main.

public static void main(String[] args) {
    BarCodeBuilder bb = new BarCodeBuilder();
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    bb.setCodeText("12345678");
    // Generate bar code image
    Image image = bb.generateBarCodeImage();
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) Image(java.awt.Image)

Example 54 with BarCodeBuilder

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

the class RenderBarcodeToServlet method doGet.

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    BarCodeBuilder b = new BarCodeBuilder();
    b.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    b.setCodeText("12345678");
    BufferedImage image = b.getBarCodeImage();
    response.setContentType("image/png");
    OutputStream outputStream = response.getOutputStream();
    ImageIO.write(image, "png", outputStream);
    outputStream.close();
}
Also used : OutputStream(java.io.OutputStream) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) BufferedImage(java.awt.image.BufferedImage)

Example 55 with BarCodeBuilder

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

the class BarcodeImageResolution method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(BarcodeImageResolution.class) + "BarcodeImage/UtilityFeatures/";
    // Instantiate barcode object
    BarCodeBuilder bb = new BarCodeBuilder();
    // Set the Code text for the barcode
    bb.setCodeText("1234567");
    // Set the symbology type to code128
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    // Create an instance of resolution and apply on the barcode image with
    // customized resolution settings
    bb.setResolution(new Resolution(200f, 400f, ResolutionMode.Customized));
    // Save the image
    bb.save(dataDir + "barcode-image-resolution.jpg");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) Resolution(com.aspose.barcode.Resolution)

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