This is really a "how to" question. I have written a java program which reads Zebra ZPL text, parses it and renders it on screen. I am working my way through all the barcode types, matching the ZPL parameters for each barcode type to the Barcode4j API in an attempt to replicate what a Zebra printer would do. So far - so good.
However I'm now working on the Aztec Barcode, something which I'm not that familar with and I find a lot of ZPL parameters which don't seem to have an Barcode4j equivalent API.
I have attached the relevant pages from the Zebra manual which seems to use ^B0 and ^BO for Aztec (not sure if that's actually correct or a typo).
If you have time could you let me know which of the ZPL parameters have equivalents for Barcode4j. I am trying to control the size of the output with little success. Am I suppose to the the Barcode4j setWidth and setHeight or use the Magnification Factor.
I would prefer to be able to control the barcode using the data from the ZPL.
I have also attached a class which is used to collect the ZPL parameters and then use the same values to create the barcode. As you may notice I'm only using a fraction of them at the moment and not having much luck with magnification. Many of the other barcode types seem to inherit values from the ^BY but not so with Aztec.
public class ZPLBarcode_Aztec
{
private ZPLUtility util = new ZPLUtility();
public boolean getParameters(ZPLCmd cmd,ZPLMemory memory)
{
boolean result = true;
memory.bps.store("^BY", ZPLPropertyStore.Param_Barcode_Type, ZPLBarcode_Types.B0_Aztec);
memory.bps.store("^B0",ZPLPropertyStore.Param_Orientation,util.getStringWithDefault(cmd, 0, memory.bps.recallAsStringWithDefault("^FW",ZPLPropertyStore.Param_Orientation, "N")));
memory.bps.store("^B0",ZPLPropertyStore.Param_Magnification,(util.getIntWithDefault(cmd, 1, 3)));
memory.bps.store("^B0",ZPLPropertyStore.Param_ECICs,(util.getStringWithDefault(cmd, 2, "N")));
memory.bps.store("^B0",ZPLPropertyStore.Param_Error_Control_Symbol_Size_Type,(util.getIntWithDefault(cmd, 3, 33)));
memory.bps.store("^B0",ZPLPropertyStore.Param_Menu_Symbol_Indicator,(util.getStringWithDefault(cmd, 4, "N")));
memory.bps.store("^B0",ZPLPropertyStore.Param_No_Of_Symbols,(util.getIntWithDefault(cmd, 5, 1)));
memory.bps.store("^B0",ZPLPropertyStore.Param_Optional_ID_Field,(util.getStringWithDefault(cmd, 6, "")));
memory.bps.store("^B0",ZPLPropertyStore.Param_Barcode_Height,util.getIntWithDefault(cmd, 2, memory.bps.recallAsIntegerWithDefault("^BY",ZPLPropertyStore.Param_Barcode_Height, 100)));
memory.bps.store("^B0",ZPLPropertyStore.Param_Barcode_Interpretation,(util.getStringWithDefault(cmd, 3, "Y")));
memory.bps.store("^B0",ZPLPropertyStore.Param_Barcode_Interpretation_Above,(util.getStringWithDefault(cmd, 4, "N")));
return result;
}
public boolean create(Graphics g,float magnification,ZPLMemory memory)
{
boolean result = false;
Graphics2D g2d = (Graphics2D) g;
AztecBean bean = new AztecBean();
bean.setErrorCorrectionLevel(memory.bps.recallAsIntegerWithDefault("^B0", ZPLPropertyStore.Param_Error_Control_Symbol_Size_Type,0));
BufferedImage barcodeImage;
try (ByteArrayOutputStream out = new ByteArrayOutputStream())
{
BitmapCanvasProvider canvas = new BitmapCanvasProvider(out, "image/png", 300, BufferedImage.TYPE_BYTE_BINARY, false, 0);
String barcodeData4j = (memory.bps.recallAsStringWithDefault("^FD",ZPLPropertyStore.Param_Text,""));
bean.generateBarcode(canvas, barcodeData4j);
canvas.finish();
barcodeImage = ImageIO.read(new ByteArrayInputStream(out.toByteArray()));
g2d.drawImage(barcodeImage, memory.bps.recallAsIntegerWithDefault("^FO", "X",0), memory.bps.recallAsIntegerWithDefault("^FO", "Y",0), null);
result = true;
}
catch (IOException e)
{
e.printStackTrace();
}
return result;
}
This is really a "how to" question. I have written a java program which reads Zebra ZPL text, parses it and renders it on screen. I am working my way through all the barcode types, matching the ZPL parameters for each barcode type to the Barcode4j API in an attempt to replicate what a Zebra printer would do. So far - so good.
However I'm now working on the Aztec Barcode, something which I'm not that familar with and I find a lot of ZPL parameters which don't seem to have an Barcode4j equivalent API.
I have attached the relevant pages from the Zebra manual which seems to use ^B0 and ^BO for Aztec (not sure if that's actually correct or a typo).
If you have time could you let me know which of the ZPL parameters have equivalents for Barcode4j. I am trying to control the size of the output with little success. Am I suppose to the the Barcode4j setWidth and setHeight or use the Magnification Factor.
I would prefer to be able to control the barcode using the data from the ZPL.
AZTEC.pdf
I have also attached a class which is used to collect the ZPL parameters and then use the same values to create the barcode. As you may notice I'm only using a fraction of them at the moment and not having much luck with magnification. Many of the other barcode types seem to inherit values from the ^BY but not so with Aztec.
`
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.krysalis.barcode4j.impl.aztec.AztecBean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
}
`