RBarCode

Wellcome to RBarCode. This package contains a Java[TM] applet and a Java[TM] class you can use to create barcodes for you website or application.

BarCode

This section explains the main configuration parameters of the BarCode class. This class is a descendant of java.awt.Canvas and you can therefore use it in any container.

The names in parenthesis are the names of the applet parameters.

How to create a gif, png or jpg file.

You can also export the barcode to a gif,png or a jpeg file. In order to do this you must use the following code:

note that:

Note: this feature is only available in JDK 1.2 or later.

How to create the barcode in a java.awt.Image object

The following code illustrates how you can create a barcode in a java.awt.Image object:

bc=new BarCode();
bc.setSize(400,200); // important, set size

// create image
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage( bc.getSize().width,bc.getSize().height,java.awt.image.BufferedImage.TYPE_BYTE_INDEXED );

// get graphic context of image
java.awt.Graphics imgGraphics = image.createGraphics();

// paint barcode in graphics context of image
bc.paint(imgGraphics );

How to use the checkCharacter (CHECK_BAR) field:

If you are suppling the code with the check digit already calculated, you must set CHECK_CHAR to N (this is the default). If you want the software to calculate the checksum for you, you must set CHECK_CHAR to Y.

For EAN and UPC have fixed length and therefore you only have the following possibilities:

How to use RBarcode in a web site

You have two possibilities:

BCApplet

You can use BCApplet to display barcodes in your HTML pages.Some parameters of the applet have a special format:

Example of how to use the applet:

You can provide the parameters in the Applet PARAM tag or you can also do it from Javascript. For example, the following code set a new value for the barcode:

 

RBarcodeServlet (the servlet)

RBarcodeServlet will allow you to use RBarcode as Servlet without any Java[TM] programming. The servlet has the advantage that the Java[TM] classes must not be downloaded to the client's browser. This means your barcode will be displayed faster. It has however the disadvantage that you need to have a web server able to execute servlets.

In the case of servlets, the barcodes are created in the server and the output in GIF or JPEG format is sent to the browser. This also means that you can use RBarcode to in browsers that do not support Java[TM].

You can very easily use RBarCodeServlet. The parameters are the same as those for the applet. You can send the parameters to the Servlet using the POST or GET methods. Furthermore there are some additional parameters:

Note that

In order to run the servlet using JSWDK 1.0 you must do the following:

  1. copy the RBarcode classes to /jswdk-1.0.1/examples/Web-inf/servlets
  2. Add the following line to the file /jswdk-1.0.1/examples/Web-inf/servlets.properties :

RBarCodeServlet.code= RBarCodeServlet

  1. Start the server (startserver.bat) an test the servlet entering the following address and parameters in your browser:

    http://localhost:8080/examples/servlet/RBarCodeServlet?BARCODE=123456789012&WIDTH=50&HEIGHT=50&CODE_TYPE=EAN13&CHECK_CHAR=Y
    .. ...

  2. You can use the servlet with the POST or GET method.
  3. You can put additional parameters to modify the image format and the size:

    http://localhost:8080/examples/servlet/RBarCodeServlet?BARCODE=123456789012&WIDTH=50&HEIGHT=50&CODE_TYPE=EAN13&CHECK_CHAR=Y&FORMAT=gif&WIDTH=600&HEIGHT=600

 

Barcodes types

The following is a short description of some of the barcode types:

At HP site you will find more information abour barcode.