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");
}
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);
}
Aggregations