I am using barbecue 1.5.beta to generate barcode images on my Windows 2003 server.
When migrating to a new server though (Windows 2008 x64 ) I encountered the following issue: text label underneath the barcode wasn't showing any more...users where baffled by this ..and so was I .
After searching the web I came to a conclusion that this must be happening because some servers (don't ask me why) are considered to be headless (without monitor) and in that case...well there is a bug in Barcode class namely in its calculateSize() method. Credits for this solution must go to Paul
So, to fix Barcode.class you must replace its calculateSize() method, as Paul suggested:
-------------------------------------
Works like charm. If you have enough patience you should download Barbecue source code, downland dependencies, use maven, make changes ...recompile (as I did). Or if you don't - then just take this Barbecue (myFix) version.
When migrating to a new server though (Windows 2008 x64 ) I encountered the following issue: text label underneath the barcode wasn't showing any more...users where baffled by this ..and so was I .
After searching the web I came to a conclusion that this must be happening because some servers (don't ask me why) are considered to be headless (without monitor) and in that case...well there is a bug in Barcode class namely in its calculateSize() method. Credits for this solution must go to Paul
So, to fix Barcode.class you must replace its calculateSize() method, as Paul suggested:
-------------------------------------
private Dimension calculateSize() { Dimension d = new Dimension(); if(EnvironmentFactory.getEnvironment() instanceof HeadlessEnvironment) try { if(font == null) { d = draw(new SizingOutput(font, getForeground(), getBackground()), 0, 0, barWidth, barHeight); } else { java.awt.FontMetrics fontMetrics = getFontMetrics(font); d = draw(new SizingOutput(font, fontMetrics, getForeground(), getBackground()), 0, 0, barWidth, barHeight); } } catch(OutputException e) { e.printStackTrace(); } else try { java.awt.FontMetrics fontMetrics = null; if(font != null) fontMetrics = getFontMetrics(font); d = draw(new SizingOutput(font, fontMetrics, getForeground(), getBackground()), 0, 0, barWidth, barHeight); } catch(OutputException e) { } return d; }-------------------------------------
Works like charm. If you have enough patience you should download Barbecue source code, downland dependencies, use maven, make changes ...recompile (as I did). Or if you don't - then just take this Barbecue (myFix) version.
its very helpful if you have a barcode label in your company if you want more information about barcode here visit our page
ReplyDelete