Search in sources :

Example 1 with Caption

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

the class BarcodeCaption method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(BarcodeCaption.class) + "Barcode/BasicFeatures/";
    // Instantiate Barcode object
    BarCodeBuilder bb = new BarCodeBuilder();
    // Set the code text of the barcode
    bb.setCodeText("1234567");
    // Set the symbology type to code128
    bb.setEncodeType(com.aspose.barcode.EncodeTypes.CODE_128);
    Caption caption = new Caption();
    caption.setText("Caption");
    caption.setTextAlign(com.aspose.barcode.StringAlignment.Center);
    bb.setCaptionAbove(caption);
    bb.setCaptionBelow(caption);
    bb.getCaptionAbove().setTextAlign(com.aspose.barcode.StringAlignment.Near);
    bb.getCaptionAbove().setText("Aspose.Demo");
    bb.getCaptionAbove().setVisible(true);
    bb.getCaptionAbove().setFont(new java.awt.Font("Pristina", Font.PLAIN, 14));
    bb.getCaptionAbove().setForeColor(java.awt.Color.RED);
    bb.getCaptionBelow().setTextAlign(com.aspose.barcode.StringAlignment.Far);
    bb.getCaptionBelow().setText("Aspose.Demo");
    bb.getCaptionBelow().setVisible(true);
    bb.getCaptionBelow().setFont(new java.awt.Font("Pristina", Font.PLAIN, 14));
    bb.getCaptionBelow().setForeColor(java.awt.Color.RED);
    // Save the Barcode image to file
    bb.save(dataDir + "barcodeCaption.jpg");
}
Also used : Font(java.awt.Font) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) Caption(com.aspose.barcode.Caption)

Aggregations

BarCodeBuilder (com.aspose.barcode.BarCodeBuilder)1 Caption (com.aspose.barcode.Caption)1 Font (java.awt.Font)1