WOBarcode Framework
This Library uses a Commercial Product, that's why it is not in the Wonder Project itself.
You can buy this Package from http://www.java4less.com/barcodes/barcodes.php
- Java J4L Barcode Suite, single company USD 210.-
- Java J4L Barcode Suite, redistribution license USD 420.-
Setup iReport
Add Classpath to iReport :
Use Barcode in iReport
Drag and Drop a Image to the Jasperform.
Set the Size.'Width' and 'Height'
Set the 'Expression Class' to
Set the 'Image Expression' 」like Sample below.
Expression Sample
(use code in Image Expression)
PDF417
Code Block |
---|
new com.java4less.rbarcode.jr.J4LBarcodeRenderer((new com.java4less.rbarcode.BarCode2DFacade()).createBarcodeImage( "This is a PDF417",null,0,0,3,1,"TEXT",1,4,20,null)) |
Datamatrix
Code Block |
---|
new com.java4less.rbarcode.jr.J4LBarcodeRenderer((new com.java4less.rdatamatrix.RDataMatrixFacade()).createBarcodeImage( "This is a Datamatrix",null,false,3,30,"AUTO",null,null)) |
QRCode
Code Block |
---|
new com.java4less.rbarcode.jr.J4LBarcodeRenderer((new com.java4less.qrcode.QRCodeFacade()).createBarcodeImage( "This is a QRCode",null,3,false,20,"H","AUTO",1,null)) |
Code39
Code Block |
---|
new com.java4less.rbarcode.jr.J4LBarcodeRenderer((new com.java4less.rbarcode.BarCodeFacade()).createBarcodeImage( "CODE39","C1005263","A","false","C-1005263",0,20,1,2,null,null,null,null,30,30,null)) |
JAN / EAN 13
Code Block |
---|
new com.java4less.rbarcode.jr.J4LBarcodeRenderer((new com.java4less.rbarcode.BarCodeFacade()).createBarcodeImage( "EAN13","1234567890982","A","false","1234567890983",0,40,1,2,null,null,null,null,30,30,null)) |
Parameter
@param type - type of barcode to create.
Valid values are:
BAR39, BAR38EXT, CODE128, CODE11, CODABAR, CODE93, CODE93EXT, MSI, IND25, MAT25, INTERLEAVED25, EAN13,
EAN8, EAN128, UPCA, UPCE or POSTNET
Sample : "EAN13"
@param value - value to be encoded
Sample : "1234567890982"
@param code128 - 'A', 'B' or 'C' (CODE128 only)
Sample : "A"
@param processTilde -
processTilde (PROCESS_TILDE): it true , the tilde character in the input data will be processed as follows:
~dNNN represents the ascii character encoded by the 3 digits NNN. For example, ~d065 represents the character 'A'.
Sample : "false"
@param text - value to be displayed below the barcode
Sample : "1234567890983"
@param rotate - rotation of the barcode, currently only value 0 supported
Sample : "0"
@param barHeight - height of bars in pixels
Sample : "40"
@param X - width of narrow bars in pixels
Sample : "1"
@param N - multiplier for wide bars. A value of 2, means that wide bars will be 2 times the width of narrow bars. The default value is 2
Sample : "2"
@param barColor - Color of bars
Valid values are RED, BLACK, BLUE, CYAN, DARKGRAY, GRAY, GREEN, LIGHTGRAY, MAGENTA, PINK, WHITE or YELLOW.
You can also use the RGB value.
Sample : "null"
@param fontColor - color of the text
Sample : "null"
@param backColor - background color
Sample : "null"
@param font - font of the text, for example "ARIAL|BOLD|10", the format is <family|style|size>
Sample : "null"
@param leftMargin - margin in pixels
Sample : "30"
@param topMargin - margin in pixels
Sample : "30"
*@param properties - currently ignored, use null
Sample : "null"
Display BarCode as an JPEG to the HTML Site
Sample Action URL
wa/barCode?id="1291898293823"
Code Block |
---|
// Display BarCode as Image Object public WOActionResults barCodeAction() { BarCode bc= new BarCode(); bc.setSize(400 , 200); bc.barType = BarCode.EAN128; bc.resolution=1; bc.leftMarginCM= 50; bc.topMarginCM= 50; bc.checkCharacter =true; bc.code = "1291898293823"; // use the request or what you like here bc.barColor = java.awt.Color.black; bc.backColor= java.awt.Color.white; bc.fontColor = java.awt.Color.blue; bc.textFont = new java.awt.Font("Arial",java.awt.Font.BOLD,14); bc.X = 1; bc.N = 3; //create bufferred image java.awt.image.BufferedImage image = new java.awt.image.BufferedImage( bc.getSize().width,bc.getSize().height,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED ); java.awt.Graphics imgGraphics = image.createGraphics(); bc.paint(imgGraphics ); ByteArrayOutputStream os=new ByteArrayOutputStream(); com.sun.image.codec.jpeg.JPEGImageEncoder encoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder(os); byte[] imageBytes = null; try { encoder.encode( (BufferedImage) image); imageBytes=os.toByteArray(); } catch (Exception e) { e.printStackTrace(); } WOResponse response = new WOResponse(); response.setContent(imageBytes); response.setHeader("image/jpeg", "content-type"); response.setHeader("Connection", "keep-alive"); response.setHeader("no-cache, must-revalidate", "Cache-Control"); // HTTP/1.1 response.setHeader("Fri, 1 Jan 2010 08:00:00 GMT", "Expires"); // Date in the past return response; } |