Jump to content
We've recently updated our Privacy Statement, available here ×

Underline in "Barbeque" barcodes


halfer

Recommended Posts

Hi all

Using both iReport or JasperServer I am trying to fix some problems with our barcode output. We use Tomcat 6 and the latest version of Barbeque, version 1.5beta1. I am somewhat concerned that this might be a problem with Barbeque, and that the Barbeque project may have been abandoned (the bug tracker has plenty of unresolved bugs and the last one fixed was November 2007).

 

Firstly we are experiencing a heavy underline in the barcode. This appears to be a fault that has been raised a number of times on the project site. There are a few code resolutions to try - but I was wondering if any JasperServer users had any experience with sorting this out? Links are here, here, here and here. The last item suggests that the bug has been fixed, but it clearly hasn't!

 

Ideally there would be a Property to set in iReport to fix this, but I reckon I might have to get my hands dirty and recompile it. Has anyone experienced this, first of all, and if so can any pointers be offered?

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

One other item, which is not nearly so important, is that the background of the barcode (snapshotted directly from iReport PDF output) is quite noisy and the resolution is quite blocky. I wonder if JPEG has been used as an interim output format?

 

On this topic I'd like to remove the noisiness and it would be even better if we could use SVG or some other vector format as an interim format, so that the end result is rendered in the PDF with no resolution limitations.

Link to comment
Share on other sites

I don't understand what causes the underline, nor how this can be worked around.  In any case, I think it will require some changes to the code that renders barcodes.

The output quality is indeed caused by the fact that the barcode renderer shipped with iReport produces a rasterized image, which is then encoded as JPEG by JasperReports.  Encoding the image as PNG would improve the quality, but it would still be a rasterized image.

Rendering barcodes as SVGs is possible, but you will need to use a different barcode image renderer (so you won't be using the iReport barcode support).  You can see such sample renderers in the "barcode" and "barbecue" samples shipped with JasperReports.  If you find those renderers usefull, you can compile and package them and use them in your reports.

Regards,

Lucian

Link to comment
Share on other sites

Thanks for your reply, Lucian, much appreciated.

 

Having iReport support is pretty important for us (though conceivably we could run all of our JRXML reports through an XML filter that "fixes up" the barcode thing I suppose). However this sounds like a bit of a hassle so I think we'll stick with what iReport gives us. Is there somewhere I can put forward SVG support inside iReports as a suggested feature?

 

Meanwhile is using PNG instead of JPEG easy to achieve in JasperReports, or would I have to change some code? I have a Java-developing colleague who can advise me on this sort of stuff, but I suspect I would actually have to do the work, and I am not a Java developer... :o)

 

I wonder also whether you know of the status of the Barbeque project? It looks like work has stalled on it. If this is the case, do you think that iReports/JasperReports may choose to move to other render engines anyway, in due course?

Link to comment
Share on other sites

  • 4 weeks later...

We're successfully using Barcode4J with SVG output in our reports. We're using the latest Netbeans-based iReport (3.1.2 I think). In iReport, it's just an image variable and the expression is a call to a renderer we've written that takes the desired value of the barcode as an argument.

Link to comment
Share on other sites

Hi, thanks for your response. Although you are using a Netbeans-based iReport, would I be right in suggesting this would work with the regular iReport application? As previously indicated my knowledge of Java is pretty limited but I am pretty hardy in giving things a go where necessary.

 

I shall take a look at Barcode4J - thanks for the tip. Using an image variable sounds like a good idea - at least one does not have to edit the JRXML file manually to get this to work! (for our users I think this would be considered too complex a step for production workflow - only programmers would be able to edit barcodes). Is the renderer to call this library trivial? If not, would you be prepared to share some of your code? Any further hints for this Java dunce would be appreciated!

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

Implementing Barcode4J  renderers should be fairly easy, all you need is basic knowledge of the librabry.  I'm attaching a POC Code128 barcode renderer that I wrote some time ago.

HTH,

Lucian



Post Edited by Lucian Chiriţă at 03/23/09 13:58

Code:
package jr;import java.awt.Graphics2D;import java.awt.geom.Rectangle2D;import org.krysalis.barcode4j.impl.code128.Code128Bean;import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider;import net.sf.jasperreports.engine.JRAbstractSvgRenderer;import net.sf.jasperreports.engine.JRException;public class Code128Renderer extends JRAbstractSvgRenderer{	private static final long serialVersionUID = 1L;		private final String code;		public Code128Renderer(String code)	{		this.code = code;	}	public void render(Graphics2D grx, Rectangle2D rectangle)			throws JRException	{		Code128Bean barcode = new Code128Bean();		Rectangle2D barcodeDim = barcode.calcDimensions(code).getBoundingRect();		Graphics2D graphics = (Graphics2D) grx.create();		graphics.translate(rectangle.getX(), rectangle.getY());		graphics.scale(rectangle.getWidth() / barcodeDim.getWidth(), 				rectangle.getHeight() / barcodeDim.getHeight());		Java2DCanvasProvider canvasProvider = new Java2DCanvasProvider(graphics, 0);		barcode.generateBarcode(canvasProvider, code);	}}

Post Edited by Lucian Chiriţă at 03/23/09 13:58
Link to comment
Share on other sites

  • 6 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...