How to print barcodes

Hi guys
I have a lot of reports made in Jasper Reports (iReport), but now I have necessity to add a barcode in every report. With advanced plugin I have a problem (as explained in an other topic ). Also I have notice that barbecue is a beta plugin (barbecue-1.5-beta1.jar) made in 2007. I ask, now it’s still used this plugin? Why there is not a final release of its?
So I wanna ask you if there are others solutions to print barcodes (I’ve read about Velocity but this means that add another program for reports…) or Jasper Plugin is the right way.

Thanks in advance!

Luca

I have been using the barcode from IT2BE with success - but not from within an iReport - from a Servoy form. Would that work for your case?
Have a look here:

There’s no issue with having both JasperReports and VelocityReport in your plugins. I know quite a few solutions in production that are using both, depending on the type of report and data they are producing. In any case, there’s no harm having both in your plugins folder.

VelocityReport can produce bar codes that you can use as a simple image, in the end it’s just a URL, so you can embed it into any form, report or html page, so I bet you could pass the URL parameter produced by plugins.VelocityReport.getBarcode() as parameter to Jasper…

Thanks Patrick for your reply!
Currently this is the only way!

I hope this will give you the occasion to give VelocityReport a better try.
You’ll see that it’s easy to work with and it’s a Jasper killer for some reports, especially those with flexible layouts…

Yes, I’ve notice that Velocity is better in case of flexible layouts and maybe Jasper in case of tables or simple layout.

ptalbot:
There’s no issue with having both JasperReports and VelocityReport in your plugins. I know quite a few solutions in production that are using both, depending on the type of report and data they are producing. In any case, there’s no harm having both in your plugins folder.

VelocityReport can produce bar codes that you can use as a simple image, in the end it’s just a URL, so you can embed it into any form, report or html page, so I bet you could pass the URL parameter produced by plugins.VelocityReport.getBarcode() as parameter to Jasper…

Hello
How can I pass the URL produced by velocity.getBarcode() as parameter to Jasper?
Which is the correct class of the parameter? and in Ireport is necessary to put in form an image object? which expression class?
Thank you very much
Regards
Roberto

VelocityReport.getBarCode() returns a BarcodeWrapper object. This object’s toString() method will give you a full tag suitable to use in HTML_AREA or in VelocityReport’s templates.

But I’ve just added a getURL() method (in v2.0.29, so update) that will allow you to retrieve the pure URL of that barcode, this URL is a String.

Now you can do something like that:

var barcodeDefinition = {
	data: "ServoyStuff",
	gray: true,
	type: BARCODE.CODE128,
	height: 60,
	pattern: "______-_____!",
	moduleWidth: "0.18mm",
	wideFactor: 3,
	format: "png",
	fontSize: 8,
	forcedWidth: 225,
	forcedHeight: 90,
	id: "barcode1",
	font: 'Courier+New',
	resolution: REPORT.RESOLUTION_HIGH
}
var barcode = plugins.VelocityReport.getBarcode(barcodeDefinition);
var report_bytes = plugins.jasperPluginRMI.runReport(db,reportName,null,OUTPUT_FORMAT.PDF,{'imageURL': barcode.getURL()});

In IReport you will need to define an Image object. The Image Expression will be $P{imageURL} and its Expression Class will be java.lang.String.

Hope this helps.

Hi Patrick

I tried but didn’t work.
I set in Ireport the parameter and the image object class java.lang.String
I get the URL with “barcode.getURL()” but didn’t work.

I tried with:
var v_url = barcode.getURL();
var v_bytes = plugins.http.getMediaData( v_url );
var v_img = new Packages.java.io.ByteArrayInputStream( v_bytes );
v_img = Packages.javax.imageio.ImageIO.read( v_img );
and pass the variable “v_img” to a param defined java.awt.Image ( the image object class is java.awt.Image ) and works.

I used Ireport 4.0.0 and plugin 3.3.0
Thanks for support
Bye
Roberto

I think that is a plugin problem.
I put the barcode URL in a string parameter ( default value ) and set the image object class to java.lang.String, the preview launched from Ireport works.

Regards
Roberto

Definitely a Jasper plugin issue then. Because VelocityReport is returning a woking URL.

Ok I think too.

No one from servoyforge can help me?

Thank you very much!
Bye
Roberto

Hi Roberto,

Did you file a ticket on the JasperReports plugin project yet?

Created a ticket in servoyForge
Thank you Robert

Issue closed in ServoyForge, adding resolution here (as closed in https://www.servoyforge.net/issues/575):

Please use com.servoy.plugins.jasperreports.JasperReportsResourceLoader.loadImage(…) and have extra directories set, as noted in https://www.servoyforge.net/boards/13/topics/644.

Regards,
Andrei

Thanks to all for support.
Bye
Roberto

Hi, I have experience of creating barcode in Java. As for creating barcode in Jasper Report, you may read this article. As for creating barcode in iReport, you can read this article. Hope this can be of some help.

I am attracted by the title of this thread for I am having similar problems like how to use bar code in jasper reports in java. I visited many barcode tools sites but got no ideas. The discussions here are so insightful, offering me much hints.

Moderator: Your message doesn’t match your link references. In fact the way this post was constructed is very much considered spam. All the extra links and colors are now removed. Please stay on topic.

Refer to the follow:
print bar codes in ireports
print bar codes in jasper reports
I 'm sure the above will be help.

Too bad for the exception when using barcodes :