Streaming Barcode Images in JasperReports iReport Designer

In this tutorial, the Dynamic Barcode Generator Service is used to show how to stream barcodes in Jaspersoft iReport Designer 5.5, and later versions should be a similar process, if not the same. iReport Designer is the free, open-source report designer for JasperReports and JasperReports Server.

iReport and Dynamic Barcode Generator Service Overview

Barcodes can be easily implemented in a report by placing the IDAutomation Barcode Generator Service URL into an image item and setting the URL parameter to a desired field. When the report is run, scannable barcodes are streamed to the browser or directly to PDF.

Report Builder Example

Buy License

iReport and Dynamic Barcode Generator Service Tutorial

Applications Used in this Tutorial
  • This tutorial uses the Free Version of the Dynamic Barcode Generator Service; the purchased version does not include the watermark.
  • Jaspersoft iReport Designer 5.5
  • Microsoft Excel
Tutorial

NOTE: The tutorial uses iReport Designer 5.5 and an Excel data source to generate a Code 128 barcode based on the Dynamic Barcode Generator Service Demo.

Excel Data Source

Data Source

  1. To run Jaspersoft iReport, double-click the application icon.
    iReport Icon
  2. Select File - New. From the New file options, select Report, choose the template, and select Open this Template.
     
  3. Enter a Report name, and the location to save the report, and select Next.

  4. Select Finish.

  5. Select the Report Datasources icon.
     Report Datasources icon
  6. In the Connections/Datasources dialog box, select New, choose the data source type to import, and click Next.

  7. Choose a name for the data source, then select Browse and open the desired file. To obtain the column name for each row, select Get columns name from the first row of the file.
    Get columns name from the first row of the file.
  8. Choose Save and Close.

  9. Select the Report query icon.
     Report query icon
  10. Select the Datasource tab. This tutorial uses Excel Datasource.

  11. Select Get fields from the data source and choose OK.

  12. The report will appear in Design mode. To add the Palette (which includes report elements), select Window - Palette.

  13. Left-click and drag an Image item from the Report Elements to the Detail band of the report.
    Image item
    A dialog will open, select Cancel.

  14. Left-click the Image item, then select Properties on the right side of the application. If the Properties panel options are not visible, select Window - Properties.

  15. Within the Image properties, set the Expression Class to java.net.URL.
    Set the Expression Class to java.net.URL
  16. Select the Image Expression editor button.
    Image Expression editor button
    Enter new java.net.URL("https://www.bcgen.com/demo/linear-dbgs.aspx?D=" + $F{Product Number}) and select OK.
     Enter new java.net.URL
    In the example, the Product Number field is set to the DataToEncode (D parameter). To set additional parameters, view the Dynamic Barcode Generator Service parameter table.

  17. Set up the report title, fields, and column headers.
    Set up the report title, fields, and column headers
  18. Save the file.

  19. To view the report, select the Preview tab.
    Select the Preview tab

If a scanner is needed, consider purchasing the IDAutomation USB Barcode Scanner.