2004 IR Help Posted August 31, 2006 Share Posted August 31, 2006 By: lgbuffa - lgbuffa2004 Barcode 2004-03-22 03:28 Hello folks, I want know how to use a barcode in iReport. Can someone give a step-by-step example? Thanks a lot! By: Kees Kuip - keeskuip RE: Barcode 2004-03-22 10:21 see : http://sourceforge.net/forum/message.php?msg_id=2363827 By: lgbuffa - lgbuffa2004 RE: Barcode 2004-03-22 12:39 Thanks for help me, but where do I have to write this code?At Image component? By: Alex Kotchnev - polrtex RE: Barcode 2004-03-22 20:04 lgbuffa, You could possibly: 1. create a little bean (plain old java class - e.g. BarcodeConvert) in your classpath that receives a string and retuns an image. 2. Then, create a variable (e.g. variable bcdConverter) to hold a reference to that bean (e.g initial value: new BarcodeConvert() ). 3. Finally, wherever you need this barcode inserted, put $V{bcdConverter}.toImage("Your barcode string") I believe you could accomplish the same if you place the code in the referenced message in a scriptlet, attach the scriptlet to your report, and call the scriptlet method wherever you need the barcode inserted... I hope this helps. Alex By: lgbuffa - lgbuffa2004 RE: Barcode 2004-03-25 05:48 Thanks for help, but I solved the problem using a scriptlet.There's the code: import java.awt.Color; import java.awt.Image; import com.lowagie.text.pdf.BarcodeInter25; import dori.jasper.engine.JRDefaultScriptlet; import dori.jasper.engine.JRScriptletException; public class BarCodeScriptlet extends JRDefaultScriptlet { public void afterReportInit() throws JRScriptletException { Image image25; BarcodeInter25 code25 = new BarcodeInter25(); code25.setCode((String)super.getFieldValue("BARCODE")); code25.setBarHeight(60); image25 = code25.createAwtImage(Color.black, Color.white); super.setVariableValue("CODE", image25); } } 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