Java Barcode Generator, .NET Barcode Generator for C#, ASP.NET, VB.NET
HOME BARCODE FOR JAVA PURCHASE


BarcodeLib.com Home > Java Barcode Developer Guide > Generation Barcodes in Eclipse BIRT Reporting

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



Quick Navigate
* We are using BIRT 2.2.2 to test our Barcode for Java library.
If developer can find any problem with previous version of BIRT, please send email to support@barcodelib.com.




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:

  • Put an image on the report

  • Define "Dynamic Image" as Type

  • click "Select Image Data" Button

  • In the DataBinding Dialog click the "Add..." Button

  • define "foo" as "Column Binding Name"

  • define "Any" as "Data Type"

  • click Expression button

  • use the following expression:

  • reportContext.getAppContext().get("imageBarcode");

  • 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.