How to print barcodes

Questions and answers on developing, deploying and using plugins and JavaBeans

How to print barcodes

Postby sceresini » Thu Sep 20, 2012 5:22 pm

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
sceresini
 
Posts: 28
Joined: Tue Feb 21, 2012 3:24 pm

Re: How to print barcodes

Postby Thomas Parry » Fri Sep 21, 2012 4:08 pm

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:
https://www.servoyforge.net/projects/it2be-barcode
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: How to print barcodes

Postby ptalbot » Fri Sep 21, 2012 4:27 pm

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...
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How to print barcodes

Postby sceresini » Wed Sep 26, 2012 11:30 am

Thanks Patrick for your reply!
Currently this is the only way!
sceresini
 
Posts: 28
Joined: Tue Feb 21, 2012 3:24 pm

Re: How to print barcodes

Postby ptalbot » Wed Sep 26, 2012 1:39 pm

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...
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How to print barcodes

Postby sceresini » Wed Sep 26, 2012 4:39 pm

Yes, I've notice that Velocity is better in case of flexible layouts and maybe Jasper in case of tables or simple layout.
sceresini
 
Posts: 28
Joined: Tue Feb 21, 2012 3:24 pm

Re: How to print barcodes

Postby robysimo09 » Thu Nov 08, 2012 6:21 pm

ptalbot wrote: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
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Re: How to print barcodes

Postby ptalbot » Fri Nov 09, 2012 12:36 am

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:
Code: Select all
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.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How to print barcodes

Postby robysimo09 » Fri Nov 09, 2012 3:42 pm

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
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Re: How to print barcodes

Postby robysimo09 » Fri Nov 09, 2012 4:38 pm

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
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Re: How to print barcodes

Postby ptalbot » Fri Nov 09, 2012 8:22 pm

Definitely a Jasper plugin issue then. Because VelocityReport is returning a woking URL.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: How to print barcodes

Postby robysimo09 » Mon Nov 12, 2012 11:36 am

Ok I think too.

No one from servoyforge can help me?

Thank you very much!
Bye
Roberto
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Re: How to print barcodes

Postby ROCLASI » Mon Nov 12, 2012 12:03 pm

Hi Roberto,

Did you file a ticket on the JasperReports plugin project yet?
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: How to print barcodes

Postby robysimo09 » Mon Nov 12, 2012 4:01 pm

Created a ticket in servoyForge
Thank you Robert
robysimo09
 
Posts: 108
Joined: Fri Sep 04, 2009 9:06 am

Re: How to print barcodes

Postby Andrei Costache » Mon Nov 19, 2012 12:20 pm

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
Andrei Costache
Servoy
User avatar
Andrei Costache
 
Posts: 196
Joined: Mon Sep 07, 2009 11:53 am

Next

Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 5 guests