How do I display text in the barcode?

1,591 views
Skip to first unread message

John Williams

unread,
Jul 24, 2013, 10:08:49 PM7/24/13
to zx...@googlegroups.com
 I'm new to Zxing and I am attempting to generate barcodes using Zing. However I unable to find any javadocs for Zxing and am having trouble displaying the barcode number on the image. Here is the code that I am using. The value is encoded and can be read, however I need the encoded value added to the image.

package barcode;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.Writer;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.ByteMatrix;
import com.google.zxing.oned.Code128Writer;
import com.google.zxing.pdf417.encoder.PDF417Writer;
import com.google.zxing.qrcode.QRCodeWriter;
import java.io.File;
import java.io.FileOutputStream;

 


public class Barcode {
 public static void main(String[] args) {
        BitMatrix bitMatrix;
        Writer writer = new QRCodeWriter();
       
        FileOutputStream fop = null;
        File file;
       
     
       

        try {
//  Write Barcode
            bitMatrix = new Code128Writer().encode("123456789", BarcodeFormat.CODE_128, 150, 80, null);
            MatrixToImageWriter.writeToStream(bitMatrix, "png", new FileOutputStream(new File("C://code128_123456789.png")));
            System.out.println("Code128 Barcode Generated.");

           
        } catch (Exception e) {
            System.out.println("Exception Found." + e.getMessage());
        }
       
 
    }
}
           
           
           
        } catch (Exception e) {
            System.out.println("Exception Found." + e.getMessage());
        }
       
 
    }
}

Regards

Sean Owen

unread,
Jul 25, 2013, 12:34:24 AM7/25/13
to zx...@googlegroups.com
Searching for 'zxing javadoc' finds it straight away: http://zxing.org/w/docs/javadoc/index.html
The library doesn't print the barcode number. You would have to add that as you want it otherwise in your program.
Reply all
Reply to author
Forward
0 new messages