From: <eva...@gm...> - 2007-06-19 10:58:30
|
Hi. My name is Fernando. I'm using your codebar generator Barcode4j. It's work fine. But when print the image into a card printer, it's not ok. I send the image that print with HP Laserjet 2420dn and the image with a Zebra 330i printer. When I print with hp printer, it works fine, but when i do the same with Zebra printer, the codebar reader can't read it (the bars are more wide). My code is: public static BufferedImage generarCodigoBarras(String codigoLegible, String tipo) throws Exception { //tipo = code39 Model modelo = new Model(tipo); modelo.setMessage(codigoLegible); BarcodeGenerator gen = modelo.getBean(); BitmapCanvasProvider provider = new BitmapCanvasProvider(300, BufferedImage.TYPE_BYTE_BINARY, true); gen.generateBarcode(provider, modelo.getMessage()); provider.finish(); BufferedImage barCodeImage = provider.getBufferedImage(); return barCodeImage; } public class Model { private String msg; private String lastType = "none"; private AbstractBarcodeBean bean; private BarcodeClassResolver resolver = new DefaultBarcodeClassResolver(); private List changeListeners = new LinkedList(); public Model(String tipo) { this.msg = ""; setup(tipo); } public String getMessage() { return this.msg; } public void setMessage(String msg) { if (msg == null) { throw new NullPointerException("Parameter msg must not be null"); } if (!this.msg.equals(msg)) { this.msg = msg; } } public AbstractBarcodeBean getBean() { return this.bean; } public void setup(String type) { if (type == null) { throw new NullPointerException("Parameter type must not be null"); } if (!lastType.equals(type)) { Class clazz; try { clazz = resolver.resolveBean(type); this.bean = (AbstractBarcodeBean)clazz.newInstance(); this.bean.setModuleWidth(UnitConv.in2mm(1.0f / 200)); //with 300 the code isn't readable. this.bean.doQuietZone(true); this.bean.setFontSize (0); } catch (Exception e) { this.bean = null; e.printStackTrace(); JOptionPane.showMessageDialog(null, "Error al crear el modelo", "IMD", JOptionPane.ERROR_MESSAGE); } lastType = type; } } } I don't know who to make that printer impress the correct codebar!! Please, somebody who can help me! Best regardas and thanks in advice. PD: sorry for my english. PD: if somebody wants see the images, send me an email. |