The encoder does not put any additional text into the image. Its purpose is to generate the barcode only. You would have to add it elsewhere.
android : BarcodeFormat.CODE_128 not displaying text
Pregunta
I made Barcode generator using ZXing Library but when barcode generate then it wont display text below barcode like
so please suggest me some solution that how to generate BARCODE CODE_128 with TEXT Here it my code:
try {
Map<EncodeHintType, Object> hints = null;
hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "ABC-abc-1234");
BitMatrix bitMatrix = new Code128Writer().encode("ABC-abc-1234", BarcodeFormat.CODE_128, 350, 150, hints);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
int[] pixels = new int[width * height];
// All are 0, or black, by default
for (int y = 0; y < height; y++) {
int offset = y * width;
for (int x = 0; x < width; x++) {
pixels[offset + x] = bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE;
}
}
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
mImageView.setImageBitmap(bitmap);
} catch (Exception e) {
// TODO: handle exception
}
No hay solución correcta
Otros consejos
To anyone, who is still searching a solution to the problem. A possible one is to create one Bitmap image for the barcode and another one for the information below the barcode. Then you can just combine/overlay or as you want the two Bitmaps into one and print the combined Bitmap! Tested with Brother LQ-720NW, everything works fine! :)
Substitute with the following:
BitMatrix bitMatrix = new Code128Writer().write( "ABC-abc-1234",
BarcodeFormat.CODE_128,
350,
150,
hints
);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow