Home Products Demos Support Integration Barcode FAQ Order Now Contact Us

 

Home:  Products:  Barcode ComponentsJava Barcode Package:  User Manual:
 

IDAutomation Java Barcode Package User Manual

A license is required for each computer this software is installed on;
this software may only be used according to the License Agreement.

Index:

Properties of the Linear BarCode class:

This section explains the main properties, methods and configuration parameters of the package. This class is a descendant of java.awt.Canvas and may be used in any java container. IDAutomation suggests leaving all properties at their defaults unless they absolutely need to be changed.

Properties and Methods (Please refer to the index of fields and methods for more detailed information)
Class Library JavaBean Applet & Servlet Default Value Comments
autoSize AutoSize see comments True If true, the size the barcode image will automatically be determined. If this is set to false, the size will need to be specified with setSize(w,h). When using the applet or servlet, autoSize will automatically be set to false if the HEIGHT and WIDTH are manually specified. Because a temp image is created to determine the size, performance is improved by specifying the size and setting autoSize to false.
barType SymbologyID CODE_TYPE CODE128
(13)
This is the type of barcode to create. Valid values for the barcode types are as follows: CODE39=0; CODE39EXT=1; INTERLEAVED25=2; CODE11=3; CODABAR=4; MSI=5; UPCA=6; IND25=7; MAT25=8; CODE93=9; EAN13=10; EAN8=11; UPCE=12; CODE128=13; CODE93EXT=14; POSTNET=15; PLANET=16; UCC128=17; ONECODE=18; the default is CODE128. Use the number value for the JavaBean and the text value for the applet and servlet. For example, the servlet query string would include: &CODE_TYPE=ONECODE
backColor Background BACK_COLOR WHITE The background color of the barcode. It is recommended to use the default setting of WHITE. Valid values are: RED, BLUE, GREEN, BLACK, GRAY, LIGHTGRAY, WHITE, DARKGRAY, YELLOW, ORANGE, CYAN and MAGENTA. The RGB numerical value of a color can also be used as a parameter (e.g. 0x00FF00 for green).
barColor Foreground BAR_COLOR BLACK The color of the bars. It is recommended to use the default setting of BLACK. Valid values are: RED, BLUE, GREEN, BLACK, GRAY, LIGHTGRAY, WHITE, DARKGRAY, YELLOW, ORANGE, CYAN and MAGENTA. The RGB numerical value of a color can also be used as a parameter (e.g. 0x00FF00 if green).
barHeightCM BarHeightCM BAR_HEIGHT 1 The height of the bars in CM, which also adjusts the entire height of the barcode.
bearerBarHori bearerBarHorizontal BEARERBAR_HORIZONTAL 0 The size of the horizontal bearer bars. Valid values are 0-10 which are a multiple of X.
bearerBarVert bearerBarVertical BEARERBAR_VERTICAL 0 The size of the vertical bearer bars. Valid values are 0-10 which are a multiple of X.
characterGrouping characterGrouping CHARACTER_GROUPING 0 The number of digits which will be grouped together in the human readable text. Valid values are 0,3,4, and 5.
CODABARStartChar CODABARStartChar CODABAR_START A Start character for CODABAR. Valid values are "A", "B", "C" or "D".
CODABARStopChar CODABARStopChar CODABAR_STOP B Stop character for CODABAR. Valid values are "A", "B", "C" or "D".
code DataToEncode BARCODE na This is the data text to be encoded in the barcode. The input is a string value type. A byte array may also be use in PDF417 or DataMatrix.
code128set Code128Set CODE128_SET 0 The set of characters to be used in Code 128. Valid values are: 0, A, B or C. 0 is used for the automatic selection. It is recommended to leave this at the default setting. More about Auto Function...
checkCharacter CheckCharacter CHECK_CHAR Y If true, the software will calculate the check character automatically. The applet and servlet convert "Y" to true and "N" to false.
fontColor TextFontColor FONT_COLOR BLACK The color of the text below the barcode. Valid values are: RED, BLUE, GREEN, BLACK, GRAY, LIGHTGRAY, WHITE, DARKGRAY, YELLOW, ORANGE, CYAN and MAGENTA. The RGB numerical value of a color can also be used as a parameter (e.g. 0x00FF00 if green).
barCodeEncoder format (see example) (see example) FORMAT JPEG Determines the format of the image when using the servlet or saving a barcode image to a file. Valid values are GIF and JPEG. The GIF files generated are typically 4 to 20 times smaller in size than the JPEG files.
leftMarginCM LeftMarginCM LEFT_MARGIN .3 The left margin in CM. This may need to be increased for UPC and EAN barcode types.
N NarrowToWideRatio N 2 The wide to narrow ratio. A value of 2 (the default), means that wide bars will be 2 times the width of narrow bars. This setting is only valid for barcode types that support an N dimension such as Code 39 and ITF.
resolution PixelsPerCM na 38 The resolution used to create the X dimension and other measurements in pixels; Default is 38 Pixels Per CM which is about 96 DPI. 96 DPI is the resolution of the web browser; this setting works best when using the servlet or when creating images for the web browser. More information about setting the resolution and x dimension is provided in our Java Resolution KB Article.
rotate RotationAngle ROTATE 0 Indicates the angle of the barcode. Valid values are 0 (normal), 90 (vertical), 180 (inverted) and 270 (inverted vertical).
setFont Font TEXT_FONT Arial The font used to display the human readable code. To change the font in the class library, use the following syntax:
  Font newFont = new Font("Arial",Font.PLAIN,30);
  bc.setFont(newFont);
and to change the font in the applet or servlet, use this syntax:
 &TEXT_FONT=ARIAL|BOLD|12
setSize Size WIDTH, HEIGHT Null Sets the size in pixels of the barcode image. If the size is set manually, autoSize must be turned off. When using the applet and servlet, autoSize is automatically set to false if the HEIGHT and WIDTH are manually specified.
setProcessTilde ProcessTilde PT TRUE If true (or "Y" when using the applet or servlet) the tilde (~) will be processed as explained here. The default is True.
showText ShowText ST Y If this value is true, the human readable text will be displayed with the barcode. The applet and servlet convert "Y" to true and "N" to false.
textMarginCM TextMarginCM TEXT_MARGIN 0.3 The amount of space between the barcode and the human readable text.
topMarginCM TopMarginCM TOP_MARGIN .2 The top margin of the barcode (also know as the quiet zone).
UPCESystem UPCESystem UPCE_SYSTEM 0 The encoding system to be used for UPC-E compression, valid values are 0 and 1. The default is 0.
whiteBarIncrease whiteBarIncrease WHITEBAR_INCREASE 0 The percentage of the XDimension to increase the white bars. Valid options are 0-99.
X XDimensionCM X .03 This setting adjusts the width in centimeters of narrow bars, which also adjusts the entire width of the barcode. More information about setting the resolution and x dimension is provided in our Java Resolution KB Article.

JPEG or GIF file encoder example

High quality GIF and JPEG images may be easily created with the encoder. Before creating a JPEG file with the Java Package, the following requirements must be met:

  1. Place the jar or class files in the CLASSPATH - in Windows®, this is accomplished by modifying the CLASSPATH environment variable to include the full path to the JAR file. For example, the following will add LinearBarCode.jar to the classpath:
    SET CLASSPATH=.;c:\java\classroot\;c:\jars\LinearBarCode.jar
    The files in the JAR file may also be extracted to the classpath root, making sure the proper directories defined in the JAR are created.
  2. Make sure the period (this represents the current directory) is in the classpath as in the example above.
  3. Install JDK 1.2 or above or verify that JDK 1.2 or above is installed on the server. The encoder requires Java 2 or JDK 1.2 or above to create the JPEG files used by the servlet.
    Special requirements for Linux and UNIX servers:

How to create a JPEG or GIF image file:

This is a very simple example of the Java source code used to create an image file from the Linear Java Barcode Package.

Additional examples are provided in the package download for each symbology.

Java Barcode Servlet Implementation and Example

IDAutomation's Java Servlets may be used to add server-side barcode generation capability to a dedicated web server. IDAutomation's Servlet is compatible with all browsers and is easy to embed in HTML as an image with the <IMG> tag.

Servlet Implementation:

IDAutomation offers a tutorial for servlet implementation with Apache Tomcat. Additional examples are provided below.

Example Using JSDK:

  1. Place the barcode JAR or class files in the CLASSPATH. In Windows®, this is accomplished by modifying the CLASSPATH environment variable to include the full path to the JAR file. As an example, the following will add LinearBarCode.jar to the classpath:
    SET CLASSPATH=.;c:\java\classroot\;c:\jars\LinearBarCode.jar
  2. Install JDK 1.2 or above or verify that JDK 1.2 or above is installed on the server. The encoder requires Java 2 or JDK 1.2 or above to create the JPEG files used by the servlet.
    Special requirements for Linux and Unix servers:

    1. Be sure Java.awt GUI functions are available in the environment. If the Java environment has the java.awt library stripped out, then the encoder will be unable to create image files.
    2. If the UNIX or Linux server does not have an X-Window environment, then either (1) use Headless Java or (2) connect to a remote X Server or (3) install the X Windows environment and run an X Windows session or (4) install an emulator, PJA library or virtual frame buffer as described in the XWindow Error KB Document. If the server has problems with the X-Windows environment and the situation cannot be modified, consider using IDAutomation’s Dynamic Barcode Generation Service which is a fault tolerant, hosted product that performs the same functions of the Java servlet.
  3. Install the appropriate servlet server code on the server and make sure it is specified in the CLASSPATH. For example:
    SET CLASSPATH=.;c:\java\classroot\;c:\jars\LinearBarCode.jar;c:\jsdk2.1\server.jar;c:\jsdk2.1\servlet.jar
  4. Per the JSDK instructions, edit c:\jsdk2.1\examples\WEB-INF\servlets.properties to include the following statement:
    LinearServlet.code=com.idautomation.linear.IDAutomationServlet
  5. Next, start the servlet server by executing C:\jsdk2.1\startserver.bat.
  6. After the servlet server is started, type the following code into the browser and specify applet parameters to create the barcode. This URL creates the a barcode encoding "12345678" with a height if .8cm:
    http://localhost:8080/examples/servlet/LinearServlet?BARCODE=12345678&BAR_HEIGHT=.8

Servlet Implementation Using ServletExec ISAPI on Windows® Server:

  1. In the servlet administration area choose Configure.
  2. Choose Add Servlet and enter the servlet name, class and code base.
  3. Choose Submit and choose to Reload the new servlet.
  4. The servlet should now be viewable online by entering a URL such as
    http://yourserver.com/servlet/LinearServlet?BARCODE=12345678

Inserting barcodes into HTML - after the servlet is working:

  1. Barcodes may be integrated within web pages and HTML forms by using an IMG tag, for example:
    <img src="http://idautomation.reinvent.ws/servlet/LinearServlet?HEIGHT=80&WIDTH=170&BARCODE=12345678&BAR_HEIGHT=.8">
    Notice in the above code that the HEIGHT and BAR_HEIGHT are different. The HEIGHT and WIDTH parameter should be set to the maximum allowed barcode size within a form.
  2. The image that is created defaults to the screen resolution of 96 DPI and may be compressed if necessary to obtain smaller X dimensions or precision. Because of the screen’s resolution, the X dimension can only be adjusted within increments of .03cm. For example, if an X dimension of .015 is needed, the image on the web page must be compressed by 50%. The following HTML tag reduces the image by 50%; it will not look correct on the screen but it will print correctly.
    <IMG height=40 alt="Barcode Image" src="http://javabarcoding.com/servlet/lin?HEIGHT=80&WIDTH=160&BARCODE=12345678" width=80>

Creating secure servlets:

Other methods of servlet operation can be accomplished by developers that modify the servlet source code provided. This may be necessary to make sure the end-user cannot manipulate the servlet. A working example is provided in the IDAutomationSecureServlet.java file which is in the source code ZIP file in the package.

Auto-sizing and performance considerations:

When using the Servlet, auto sizing of the image is disabled if the HEIGHT and WIDTH are manually specified. Because a temp image is created to determine the size, performance is improved by specifying the size.

java.awt.Image object Implementation

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

BarCode bc=new BarCode();
bc.setSize(400,200);
// 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 );

Barcode Applet Implementation

An applet can easily display barcodes in HTML pages. However, applets do not always work on all web browsers, more about applet problems....

Example of how to use the applet in HTML:

The size must be specified when using the applet. Parameters can be provided in the Applet PARAM tag or from Javascript. For example, the following code will set a new value for the barcode:

An example of using the applet is provided in the ZIP file download. The file is named "LinearAppletTest.html".

Applet Pre-Loading

The time it takes to create barcodes on web pages using applets can be reduced by pre-loading the applet on a previous page. This type of implementation places the JAR file in the browser's cache and allows quick barcode generation - even over slow dial-up lines. The following JavaScript code pre-loads the Linear Barcode Package.

<APPLET
CODE = "com.idautomation.linear.BCApplet"
ARCHIVE = "LinearBarCode.jar"
NAME = "PreloadApplet"
WIDTH = 1 HEIGHT = 1 HSPACE = 0 VSPACE = 0 ALIGN = top >
</APPLET>

Barcodes Types Supported in the Linear Package

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

PDF417 Properties:

This section explains the main properties, methods and configuration parameters of the PDF417 package. For a more complete list, review the index of fields and methods. Specific implementation examples and code may be found within the 2D package. Additional information about this symbology is provided in the PDF417 Symbology FAQ.

Properties and Methods (Please refer to the index of fields and methods for more detailed information)
Class Library JavaBean Applet & Servlet Default Value Comments
binaryCode na na null The data (as a byte array) to be encoded in the barcode
(see class barCodeEncoder in the encoderDoc folder of the package)   FORMAT JPEG Determines the format of the image when using the servlet or saving a barcode image to a file. Valid values are GIF and JPEG. The GIF files generated are typically 4 to 20 times smaller in size than the JPEG files.
MacroPDFEnable macroPDFEnable na FALSE Determines if the barcode being created will be part of a MacroPDF barcode.
MacroPDFFileID macroPDFFileID na 0 Sets the id of the barcode in a sequence of barcodes for MacroPDF. Each MacroPDF barcode in a sequence must have the same File ID so the reader can reassemble them correctly.
MacroPDFLastSegment macroPDFLastSegment na FALSE Determines if this barcode in a sequence of MacroPDF barcodes is the final segment.
MacroPDFSegmentIndex macroPDFSegmentIndex na 0 Sets the index number of this barcode in a sequence of MacroPDF barcodes.  Each barcode in the sequence must have a unique segment index. Readers will reassemble the barcode in the order of the segment index.
PDFColumns PDFColumns COL 5 The number of columns in the symbol. Increasing this value creates a wider symbol that is less in height. Use this property to size the symbol.
PDFECLevel PDFErrorCorrection ECL 2 The error correction level for PDF417. The range is from 0 to 8.
PDFMode PDFMode MODE BINARY In the applet and servlet, the PDF417 mode can be set to NUMERIC, TEXT or BINARY. In the class library and JavaBean, the PDF417 mode can be set to one of the following numbers; 0=BINARY, 1=TEXT or 2=NUMERIC.
PDFRows PDFRows ROWS 0 The number of rows for PDF417. It is not recommended to set this number because the number of rows is automatically generated and an incorrect number can cause the symbol to be too large. Please set the PDF Columns instead to adjust the size.
truncated Truncated TRN FALSE A setting of true will enable truncation. A truncated PDF417 symbol is more area efficient than normal PDF417. By selecting this option, the right hand side of the PDF417 is removed or truncated. This option should only be used in clean environments since it is less immune to damage. The servlet and applet converts "Y" to true and "N" to false.
XtoYRatio XtoYRatio XYR 3 The X multiple height of individual cells. This is usually set between 3 and 5. A higher number creates an easier to read, taller symbol.
 
DataMatrix Properties:

This section explains the main properties, methods and configuration parameters of the package. For a more complete list, review the index of fields and methods. Specific implementation examples and code may be found within the 2D package. Additional information about this symbology is provided in the DataMatrix Symbology FAQ.

Properties and Methods (Please refer to the index of fields and methods for more detailed information)
Class Library JavaBean Applet & Servlet Default Value Comments
encoding EncodingMode MODE ASCII The encoding mode; valid values are E_ASCII, E_C40, E_TEXT or E_BASE256. When using the applet or servlet, exclude the "E_"; for example, use TEXT instead of  E_TEXT. When using the JavaBean, use the "setEncodingMode" field and enter the appropriate number for the desired mode:
  • 0=E_ASCII (default)
  • 1=E_C40
  • 2=E_TEXT
  • 3=E_BASE256

More information about encoding modes.

(see class barCodeEncoder in the encoderDoc folder of the package)   FORMAT JPEG Determines the format of the image when using the servlet or saving a barcode image to a file. Valid values are GIF and JPEG. The GIF files generated are typically 4 to 20 times smaller in size than the JPEG files.
preferredFormat PreferredFormat PFMT -1 Sets the preferred format represented by a number; valid values are from 0 (10X10) to 23 (144X144) and from 24 (8X18) to 29 (16X48); The default value is -1 which sets this to automatic; more information about preferred format. When using the applet or servlet, enter "C" and the format all uppercase. For example, for 16 x 48 enter C16X48. If the format chosen is too small for the data to be encoded, an appropriate square symbol will be selected.
processTilde ProcessTilde PT FALSE If true (or "Y" when using the applet for servlet) the tilde (~) will be processed. More information about the tilde is explained.

MaxiCode Properties:

This section explains the main configuration parameters of the MaxiCode class. For a more complete list, review the index of fields and methods. Specific implementation examples and code may be found within the 2D package. Additional information about this symbology is provided in the Maxicode Symbology FAQ.

Properties and Methods (Please refer to the index of fields and methods for more detailed information)
Class Library JavaBean Applet & Servlet Default Value Comments
data Data DATA JPEG The data to be encoded in the barcode. For most purposes, such as creating symbols for UPS, data should be pre-formatted into a single string as described in the MaxiCode FAQ.
mode Mode MODE 2 The encoding mode. A valid value is a number from 2 to 6.
setResolution Resolution RESOLUTION 200 The resolution used to create the image in DPI; Default is 200 DPI, which is the minimum required for MaxiCode.
processTilde ProcessTilde PT TRUE If true (or "Y" when using the applet for servlet) the tilde (~) will be processed. More information about the tilde is explained.

 

For more information about the various barcode symbologies, please visit the IDAutomation.com Support Site and select the symbology from the list of symbology FAQs.

To stay informed about software updates or new products, subscribe to IDAutomation's Newsletter or RSS Feed.
 

 

Copyright © 2000-2006 IDAutomation.com, Inc. IDAutomation and BizFonts are registered trademarks of IDAutomation.com, Inc. All other trademarks mentioned are the property of their respective owners. 

Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.