Barcode Servlet
Introdcution
Barcode4J provides a simple Servlet that can be used to generate barcodes in SVG, EPS or any supported bitmap format with a URL.
Try it
Barcode4J comes with a sample web application that allows you to play with the Barcode Servlet. See the Examples page for instructions.
Usage
If you follow the example of the sample web application a URL for a barcode generated from a locally installed web container could look like this:
http://localhost:8080/barcode4j/gensvg?type=code128&msg=Barcode
Parameter | Cardinality | Description |
---|---|---|
type | required | Type of the barcode. Examples: code128 (for Code 128), ean-13, upc-e etc. The values are the same used for the org.krysalis.barcode4j.BarcodeClassResolver. |
fmt | defaults to SVG | 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. |
msg | required | The message to encode. |
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 | Determines the placement of the human-readable part. Possible values: "top", "bottom" or "none" |
hrsize | optional | Determines the font size for the human-readable part. Example: 12pt |
hrfont | optional | Determines the font to use for the human-readable part. Example: CourierNew |
res | defaults to 300dpi | (Applies to bitmaps only) Determines the resolution in dpi (dots per inch) for bitmaps. |
gray | defaults to false | (Applies to bitmaps only) Determines whether the bitmap should be created in grayscales instread of monochrome (black and white). Valid values: "true" and "false". |
Note
Not all parameters are supported by every barcode type. For example, UPC and EAN barcodes don't
support the wide factor parameter because the wide factors are fixed.
by Jeremias Märki