The plug-in that produces the barcode is many, but can use the needle printer to print on the suitable form, moreover can use the common laser scanner to scan out the demo to not many.
In this paper, the related code and tools are pro-test available.
Using tools:
Epson LQ-630K-Pin Printer
Honeywell ms9540 Laser Barcode Scanning gun
Laser printer
Difficulty:
Laser printer, no matter what encoding format, with the following code output pictures, scanning guns can be scanned out;
Needle printer printing effect is not so good, print out can not scan out, just start not know what problem, change code, change style, such as the mode, pin-type printer configuration, a variety of combination test.
Solution:
Use the following code and adjust the width of the barcode appropriately.
Also do not increase too big (too big appear uncoordinated), 15 bits (5 letters are numbers) generally normal output width is about 51mm bar, adjust to 56 can be recognized, of course, if not ideal, can be adjusted.
Demo
In addition, the Jbarcode-0.2.8.jar package is added to the project.
The project uses the Struts framework, which is configured in struts as follows:
<action name= "Barcode" class= "XX. Yy. Zzaction "> <span style=" white-space:pre "></span><result type=" stream "> <span style=" White-space:pre "></span><param name=" ContentType ">image/jpeg</param> <span style=" White-space:pre "></span><param name=" InputName ">inputStream</param> <span style=" White-space:pre "></span></result> </action>
The foreground can be called as follows
Aciton class
Import Java.awt.image.bufferedimage;import Java.io.bytearrayinputstream;import Java.io.ByteArrayOutputStream; Import Javax.imageio.imageio;import Javax.imageio.stream.imageoutputstream;import Org.jbarcode.jbarcode;import Org.jbarcode.encode.code93encoder;import Org.jbarcode.paint.baselinetextpainter;import Org.jbarcode.paint.ean13textpainter;import Org.jbarcode.paint.widthcodedpainter;public class BarcodeAction { Private Bytearrayinputstream inputstream;private String Barcode;public string Execute () throws Exception {Jbarcode Jbarcode = new Jbarcode (Code93encoder.getinstance (), Widthcodedpainter.getinstance (), Baselinetextpainter.getinstance ()); Jbarcode. Setshowcheckdigit (false); Jbarcode. Setcheckdigit (True); JBarcode. Setshowtext (false); Jbarcode. Setbarheight (10); BufferedImage bufferedimage = Jbarcode. Createbarcode (barcode); Bytearrayoutputstream output = new Bytearrayoutputstream (); Imageoutputstream imageout = Imageio.createimageoutputstream (output); Imageio.write (BufferedImage, "JPEG", imageout); Imageout.close (); inputstream = new Bytearrayinputstream (Output.tobytearray ()); Return "Success";} public void Setinputstream (Bytearrayinputstream inputstream) {this.inputstream = InputStream;} Public Bytearrayinputstream getInputStream () {return inputstream;} Public String Getbarcode () {return barcode;} public void Setbarcode (String barcode) {this.barcode = barcode;}}