Package net.sf.jasperreports.barcode4j
The Barcode4J Component
This component relies on the Barcode4J library (http://barcode4j.sourceforge.net).Unlike the Barbecue barcode component, there is only one component per Barcode4J barcode type. All the barcode's components derive from a base type which defines its common attributes.
All barcodes in this library include a code expression, which provides the textual data to be encoded in the barcode, and an optional expression that provides a pattern to be applied on the message displayed in the barcode. Delayed evaluation of the barcode can be configured using the two evaluation attributes and works in the same way as for Barbecue barcodes.
Several optional barcode rendering attributes can be set:orientation
- specifies how the barcode and any accompanying text are to be oriented when rendered. There are 4 possible values:- 0 - indicates that the barcode is to be rendered in the default orientation (which for linear barcodes is with vertical bars arranged from left to right)
- 90 - indicates that the barcode is to be rotated anti-clockwise by 90 degrees
- 180 - indicates that the barcode is to be rotated anti-clockwise by 180 degrees
- 270 - indicates that the barcode is to be rotated anti-clockwise by 270 degrees
moduleWidth
- specifies the width (in pixels) of the thinnest bar/module.textPosition
- Sets the placement of the human-readable barcode message. It has three possible values:none
- meaning no human-readable message, andbottom
andtop
.
Note that the message and barcode are oriented together as a unit, so if the orientation is set to 180 and the text position to top, the code appears reversed and the text appears upside down beneath the image.quietZone
- Specifies the width of the quiet zone (in pixels).verticalQuietZone
- Specifies the height of the vertical quiet zone (in pixels).
- Codabar barcodes have a
wideFactor
attribute that specifies the factor between the width of wide bars and the width of narrow bars. - Code128 barcodes do not have any specific attributes.
- EAN128, EAN13, EAN8, UPCA and UPCE barcodes have a
checksumMode
attribute which indicates how the check digit is to be handled. The attribute accepts four values:add
- adds the checksum to the data;check
- indicates that the data should already contain a checksum;ignore
- doesn't expect or add a checksum to the data;auto
- attempts to detect whether a checksum is already present in the data or one should be added.
- Data Matrix barcodes can be configured to render as a square or rectangle by the
shape
attribute. - Code39 barcodes have a
checksumMode
attribute, adisplayChecksum
attribute that controls whether the human-readable message shows the checksum character, adisplayStartStop
attribute which decides whether start/stop characters are to be displayed in the human-readable message,extendedCharSetEnabled
to indicate that the barcode can display characters from the entire 7-bit ASCII set,intercharGapWidth
to control the width between the characters and awideFactor
attribute. - Interleaved2Of5 barcodes can specify
checksumMode
,displayChecksum
andwideFactor
attributes with the same meanings as in Code39 barcodes. - RoyalMailCustomer and USPSIntelligentMail barcodes have a
checksumMode
attribute, anintercharGapWidth
attribute, anascenderHeight
attribute which sets the length of the bar ascender/descender, and atrackHeight
attribute which provides the height of the barcode track. - POSTNET barcodes can specify
checksumMode
,displayChecksum
andintercharGapWidth
attributes, plusshortBarHeight
for setting the height of the short bar, andbaselinePosition
which can betop
orbottom
to indicate how bars should align. - PDF417 barcode can control the number of columns and rows with the
minColumns
,maxColumns
,minRows
,maxRows
andwidthToHeightRatio
attributes. The error correction level can be set using theerrorCorrectionLevel
attribute. - QRCode barcode can control its error correction level using the
errorCorrectionLevel
attribute.
BarcodeComponent
as base class and concrete classes for each barcode type.
When a report that contains barcodes is filled, the data and attributes of the barcode are
collected into an object and passed to an image producer whose responsibility is to create
a renderer for the barcode. The image producer implements the
BarcodeImageProducer
interface. As for Barbecue barcode elements, the resulting images have the size of the
design barcode element and use RetainShape
as scale type.
Determining which image producer to use for a barcode component element relies on
custom properties defined at the element, report and global levels. The
net.sf.jasperreports.components.barcode4j.image.producer
property can
have a value of the name of the class that implements the image producer interface or an
alias that has been set for such a class, using a property of the form
net.sf.jasperreports.components.barcode4j.image.producer.<alias>
.
JasperReports has two barcode image producer implementations: one which renders the
barcode in SVG format and one which renders the barcode as a rasterized image. The
first implementation is registered under the svg
alias and is used by default;
the second one has image
as alias and can be used by changing the
net.sf.jasperreports.components.barcode4j.image.producer.<alias>
property at any level.
The SVG barcode image producer uses the Barcode4J API to export the barcode to SVG, then it creates an SVG renderer based on the Batik SVG library. Hence, this option introduces a dependency on Batik for viewing or exporting a report that includes barcodes.
The rasterized image producer draws the barcode on a PNG image which can be then displayed in the generated report. This producer uses further properties, set at the same levels as the image producer property, to allow the customization of the generated image.
-
Interface Summary Interface Description BarcodeImageProducer BarcodeVisitor QRCodeImageProducer -
Class Summary Class Description AbstractBarcodeEvaluator Barcode4jComponent Barcode4JExtensionsRegistryFactory BarcodeCompiler BarcodeComponent BarcodeDesignConverter BarcodeDesignEvaluator BarcodeEvaluator BarcodeExpressionCollector BarcodeFillComponent BarcodeFillFactory BarcodeRasterizedImageProducer BarcodeSVGImageProducer BarcodeUtils BarcodeVerifier CodabarComponent Code128Component Code39Component CompiledBarcodeFactory DataMatrixComponent EAN128Component EAN13Component EAN8Component FourStateBarcodeComponent Interleaved2Of5Component PDF417Component POSTNETComponent QRCodeBean This class is used to generate QRCode component barcode logic.QRCodeComponent Contains the main settings for the QRCode componentQRCodeRasterizedImageProducer QRCodeSVGImageProducer RoyalMailCustomerComponent UniformBarcodeVisitor UPCAComponent UPCEComponent USPSIntelligentMailComponent -
Enum Summary Enum Description ErrorCorrectionLevelEnum OrientationEnum TextPositionEnum