halfer Posted December 19, 2008 Share Posted December 19, 2008 Hi allUsing 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 More sharing options...
halfer Posted December 19, 2008 Author Share Posted December 19, 2008 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 More sharing options...
lucianc Posted December 22, 2008 Share Posted December 22, 2008 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 More sharing options...
halfer Posted December 22, 2008 Author Share Posted December 22, 2008 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 More sharing options...
mbeards Posted January 17, 2009 Share Posted January 17, 2009 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 More sharing options...
halfer Posted January 19, 2009 Author Share Posted January 19, 2009 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 More sharing options...
mvanklink Posted March 10, 2009 Share Posted March 10, 2009 Hello, I'm also interested whether the implementation of this renderer is trivial or quite hard. Can you give me a pointer to the specs or an example of such a renderer class. Link to comment Share on other sites More sharing options...
lucianc Posted March 23, 2009 Share Posted March 23, 2009 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,LucianPost Edited by Lucian Chiriţă at 03/23/09 13:58Code: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 More sharing options...
halfer Posted March 24, 2009 Author Share Posted March 24, 2009 Many thanks Lucian - that is most helpful. I will pass this over to our Java chap and see if we can make use of the general approach. Link to comment Share on other sites More sharing options...
hozawa Posted January 23, 2016 Share Posted January 23, 2016 This is an old thread but all those who reached here.Just need to modify barbecue code height of the text element in the barbecue source code. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now