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

Barcode Ireport 2.0


joker29

Recommended Posts

Hi, i'm new in this forum.

I want to insert a barcode in Ireport 2.0, but i have some problems.

When i insert a EAN13 barcode and i compile the report, in runtime i have this problem:

source text: businesslogic.BcImage.getImage.Barcode...

I resolve in part this proble moving the barcode in a different position, but if compile another time the problem persist, and i must to delete the barcode and create it another time.

if i isert a Code39(extended) barcode the problem not exist.

i hope to receive an help. thank!

Link to comment
Share on other sites

  • 3 months later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

To solve this problem, i just write some String like "" or "application_Id" on the field application Id in the barcode's form.
Looking at the source of this class, BcImage, was why i can solve this little problem, that all the morning i spend with.

 

 

size=372]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/barcodeForm.JPG

 

Post edited by: carlos.cotelo, at: 2008/03/04 10:38

Post edited by: carlos.cotelo, at: 2008/03/04 10:40

Link to comment
Share on other sites

  • 6 years later...

It's my pleasure to answer your question. Here's a sample code for you:

package br.com.tce.support;/** BcImage.java** Created on 20. April 2004, 13:21*///package it.businesslogic.ireport.barcode;/**** @author  Heiko*/import java.awt.image.BufferedImage;import net.sourceforge.barbecue.BarcodeFactory;public class BcImage {        private static net.sourceforge.barbecue.Barcode bc = null;        public static net.sourceforge.barbecue.Barcode getBarcode() {                return bc;        }        public static BufferedImage getBarcodeImage(int type, Object aText, boolean showText, boolean checkSum) {                // 2of7, 3of9, Bookland, Codabar, Code128, Code128A, Code128B, Code128C, Code39, EAN128, EAN13, GlobalTradeItemNumber, Int2of5, Int2of5, Monarch, NW7, PDF417, SCC14ShippingCode, ShipmentIdentificationNumber, SSCC18, Std2of5, Std2of5, UCC128, UPCA, USD3, USD4, USPS                String text = new StringBuffer().append(aText).toString();                try {                        switch (type) {                                case 0: bc = BarcodeFactory.create2of7(text); break;                                case 1: bc = BarcodeFactory.create3of9(text, checkSum); break;                                //case 2: bc = BarcodeFactory.createBookland(text); break;                                case 3: bc = BarcodeFactory.createCodabar(text); break;                                case 4: bc = BarcodeFactory.createCode128(text); break;                                case 5: bc = BarcodeFactory.createCode128A(text); break;                                case 6: bc = BarcodeFactory.createCode128B(text); break;                                case 7: bc = BarcodeFactory.createCode128C(text); break;                                case 8: bc = BarcodeFactory.createCode39(text, checkSum); break;                                case 9: bc = BarcodeFactory.createEAN128(text); break;                                //case 10: bc = BarcodeFactory.createEAN13(text);       break;                                case 11: bc = BarcodeFactory.createGlobalTradeItemNumber(text); break;                                //case 12: bc = BarcodeFactory.createInt2of5(text, checkSum); break;                                case 13: bc = BarcodeFactory.createMonarch(text); break;                                case 14: bc = BarcodeFactory.createNW7(text); break;                                case 15: bc = BarcodeFactory.createPDF417(text); break;                                case 16: bc = BarcodeFactory.createSCC14ShippingCode(text); break;                                case 17: bc = BarcodeFactory.createShipmentIdentificationNumber(text); break;                                case 18: bc = BarcodeFactory.createSSCC18(text); break;                                //case 19: bc = BarcodeFactory.createStd2of5(text, checkSum); break;                                case 20: bc = BarcodeFactory.createUCC128("", text); break;                                //case 21: bc = BarcodeFactory.createUPCA(text); break;                                case 22: bc = BarcodeFactory.createUSD3(text, checkSum); break;                                case 23: bc = BarcodeFactory.createUSD4(text); break;                                case 24: bc = BarcodeFactory.createUSPS(text); break;                        }                        bc.setDrawingText(showText);                        return net.sourceforge.barbecue.BarcodeImageHandler.getImage(bc);                }                catch (Exception e) {                        //generate a runtime exception, invalid value passed.                        //the user must be notified if fail                        throw new RuntimeException(e.getMessage());                        //return null;[/code]

And I also found a tutorial about how to use bar code in jasper reports in java.

Hope these references can help you solve the mistakes in generating code 39 in irepot.

Hope the post can also help some novices.

Good luck.

Link to comment
Share on other sites

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...