Print barcodes in Report Studio

This document describes the technique to print barcodes using servlets from the barcode4j project ( In our examples we are going to use Tomcat, MS SQL 2000 andthe “Go Sales and Retailers” package.

Steps

  1. Download barcode4j-2.0alpha2-bin.zip from and copy it on the server. Extract the content of the file into any desired location.
    Example: Desktop
  2. Stop Cognos 8 server if it is running.
  3. Copy the file barcode4j.war from <Extracted Folder>\barcode4j-2.0alpha2\build to <c8_location>\webapps
    Example:

  1. Start the Cognos 8 Server
    The system will automatically deploy the file into the barcode4j directory. Be sure to remove the war file from the directory.

  1. Create a report.
    As an example we created a simple report, which prints product name, price, picture, and product’s number as a barcode from the subject query “Products”.

Next, create a new data item, product number link, which represents the concatenation of the URL to the servlets and product number: ' + trim(str([gosales_goretailers].[Products].[Product number]))

  1. Modify the Image’s source type and data value, set the Image’s source type to “Data Item Value” and set the Data Item Value property to “Product number link”.
  1. Report Output

Servlet Usage:

Example:

Supported parameters
Parameter / Cardinality / Valid values / Description
type / optional / code128, ean-128, code39, codabar, ean-13, ean-8, intl2of5, upc-a, upc-e, postnet, royal-mail-cbc, pdf417, datamatrix / Type of the barcode. Examples: code128 (for Code 128), ean-13, upc-e etc. Defaults to code128.
fmt / optional / svg, eps, jpeg, tiff, png, gif / Output format of the barcode. You can use either MIME types (such as "image/svg+xml") or short format types (such as "svg" or "eps"). Supported output formats for this servlet are: SVG, EPS and any supported bitmap format. Defaults to SVG.
msg / optional / The message to encode. Defaults to 0123456789.
height / optional / Specifies the desired overall height of the barcode.
Mw / optional / The desired module width (normally the width of the narrow module). Example: 0.21mm
Wf / optional / The desired wide factor. Example: 2 or 2.5
Qz / optional / Determines the quiet zone. Example: 10mw (10 times the module width) or 1.5cm. "disable" suppressed the quiet zone.
Hrp / optional / top, bottom, none / Determines the placement of the human-readable part.
hrsize / optional / Determines the font size for the human-readable part. Example: 12pt
hrfont / optional / Fonts / Determines the font to use for the human-readable part. Example: CourierNew
Res / optional / (Applies to bitmaps only) Determines the resolution in dpi (dots per inch) for bitmaps.Defaults to 300dpi
gray / optional / true, false / (Applies to bitmaps only) Determines whether the bitmap should be created in grayscales instread of monochrome (black and white). Defaults to false

Report specifications

Please refer to report.xml file.