Our Customers
Contact Us Email: support@barcodelib.com
Home > Java Barcode Generator > Java Barcode Generation Guide > Java Barcode Generator for Eclipse BIRT
Download Barcode for Java Trial

How to Insert Barcode Images into BIRT using Barcode for Java?

BarcodeLib.com is the FIRST Commercial Provider of Java Barcode Library that supports Eclipse BIRT.
Prerequisites for Eclips BIRT Barcode Generation
We are using BIRT 2.2.2 to test our Barcode for Java library. If developer find any problem with previous version of BIRT, please send email to support@barcodelib.com.
How to Generate Barcode Images in Your Java BIRT Project?
Here is the sample source code.
     // get engine from Birt Bootstrapping...
// ...

reportDesign = engine.openReportDesign("C://foo.rptdesign");
// create task to run and render report
IRunAndRenderTask task = engine.createRunAndRenderTask(reportDesign);
// set options
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("foo.pdf");
options.setOutputFormat("pdf");
task.setRenderOption(options);
// barcode is a com.barcodelib.barcode.Linear object
byte[] bytes = barcode.renderBarcodeToBytes();
task.getAppContext().put("imageBarcode", bytes);
// run and render report
task.run();
task.close();
So this was a simple Main Class using a Birt Engine to dynamicly put a byte[] to a report Context and run the report. Now do the following in the Report Designer:
  1. Put an image on the report.
  2. Define "Dynamic Image" as Type.
  3. Click "Select Image Data" Button.
  4. In the DataBinding Dialog click the "Add..." Button.
  5. Define "foo" as "Column Binding Name".
  6. Define "Any" as "Data Type".
  7. Click Expression button.
  8. Use the following expression:
    reportContext.getAppContext().get("imageBarcode");
  9. Check the checkbox in front of the "foo" entry in dialog.
Thats all. If everything works fine, the dialogs should look like below. When you now run your report the barcode should be visible where you placed the image container.



How to Get Barcode Data from Database and Generate Barcode Images in BIRT Reports?


Back to Barcode for Java