Search in sources :

Example 1 with MarginsF

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

the class CodeTextLocation method main.

public static void main(String[] args) {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(CodeTextLocation.class) + "Barcode/BasicFeatures/";
    BarCodeBuilder builder = new BarCodeBuilder("GTIN:898978777776665655 " + "UID: 121212121212121212 " + "Batch:GH768 " + "Exp.Date:150923", com.aspose.barcode.EncodeTypes.DATA_MATRIX);
    builder.setCodeLocation(CodeLocation.Right);
    builder.setMargins(new MarginsF(0, 0, 0, 0));
    builder.save(dataDir + "codetextRight.png");
}
Also used : BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) MarginsF(com.aspose.barcode.MarginsF)

Example 2 with MarginsF

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

the class GenerateAPatchCode method generateWholePage.

public static void generateWholePage() throws IOException {
    BarCodeBuilder builder = new BarCodeBuilder("Patch T", com.aspose.barcode.EncodeTypes.PATCH_CODE);
    // in millimeters
    builder.setImageWidth(150);
    // make the same small margins
    builder.setMargins(new MarginsF(0.5f, 0.5f, 0.5f, 0.5f));
    // to hide codetext
    builder.setCodeLocation(CodeLocation.None);
    BufferedImage topImg = builder.generateBarCodeImage();
    builder.rotate(90);
    BufferedImage leftImg = builder.generateBarCodeImage();
    builder.rotate(90);
    BufferedImage bottomImg = builder.generateBarCodeImage();
    builder.rotate(90);
    BufferedImage rigthtImg = builder.generateBarCodeImage();
    BufferedImage frameImg = new BufferedImage(topImg.getWidth(), rigthtImg.getHeight() + 2 * topImg.getHeight(), rigthtImg.getType());
    // Initialize graphics object from the image
    Graphics graphics = frameImg.getGraphics();
    graphics.drawImage(topImg, 0, 0, null);
    graphics.drawImage(leftImg, 0, topImg.getHeight(), null);
    graphics.drawImage(bottomImg, 0, topImg.getHeight() + leftImg.getHeight(), null);
    graphics.drawImage(rigthtImg, topImg.getWidth() - rigthtImg.getWidth(), topImg.getHeight(), null);
    // save Patch code frame
    File outputfile = new File(Utils.getDataDir(GenerateAPatchCode.class) + "Barcode/AdvancedFeatures/" + "patch-code-frame.png");
    ImageIO.write(frameImg, "png", outputfile);
}
Also used : Graphics(java.awt.Graphics) BarCodeBuilder(com.aspose.barcode.BarCodeBuilder) MarginsF(com.aspose.barcode.MarginsF) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BarCodeBuilder (com.aspose.barcode.BarCodeBuilder)2 MarginsF (com.aspose.barcode.MarginsF)2 Graphics (java.awt.Graphics)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1