JasperReports logo version 7.0.0 Home - Samples - Configuration - Functions - FAQ - API (Javadoc)

JasperReports - Barbecue Sample

Shows how barcodes could be included in reports using the Barbecue component.

Main Features in This Sample

Barcodes (Barbecue Custom Component)

Secondary Features

Barcodes

Barcodes (Barbecue Custom Component)

Documented by Sanda Zaharia

Description / Goal
Shows how to render barcodes in a report, using the barcode component based on the Barbecue library.

Since: 3.5.2

The Barbecue Library

As shown in the Barcodes section, the use of barcodes became universal. Depending on particular needs, there are several barcode specifications, called symbologies. This sample illustrates how to use the built-in component based on the open source Barbecue library.

The Barbecue library supports the following barcode formats:

It also provides support for multiple output formats:

The Barbecue Component

To completely determine a barcode, the following pieces are needed:

The Barbecue Sample

The sample shows how can be used the barbecue component to compute various barcodes:

<parameter name="Code" class="java.lang.String">
  <defaultValueExpression><![CDATA["01234567890"]] ></defaultValueExpression>
</parameter>
...
<element kind="component y="100" width="400" height="50">
  <component kind="barbecue" drawText="true" type="Code128">
    <codeExpression><![CDATA["JasperReports"]] ></codeExpression>
  </component>
</element>
<element kind="component" y="160" width="400" height="50">
  <component kind="barbecue" drawText="true" type="Codabar">
    <codeExpression><![CDATA[$P{Code}]] ></codeExpression>
  </component>
</element>
<element kind="component" y="220" width="400" height="50">
  <component kind="barbecue" drawText="true" checksumRequired="true" barWidth="3" barHeight="20" type="Int2of5">
    <codeExpression><![CDATA[$P{Code}]] ></codeExpression>
  </component>
</element>
<element kind="component" y="280" width="400" height="50">
  <component kind="barbecue" type="Std2of5">
    <codeExpression><![CDATA[$P{Code}]] ></codeExpression>
  </component>
</element>
...

Running the Sample

Running the sample requires the Apache Maven library. Make sure that maven is already installed on your system (version 3.6 or later).
In a command prompt/terminal window set the current folder to demo/samples/barbecue within the JasperReports source project and run the following command:

> mvn clean compile exec:exec@all

It will generate all supported document types containing the sample report in the demo/samples/barbecue/target/reports directory.




© 2001- Cloud Software Group, Inc. www.jaspersoft.com