The Artima Developer Community
Sponsored Link

Java Buzz Forum
Embed barcodes in Birt w/o barcode fonts

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Marc Logemann

Posts: 594
Nickname: loge
Registered: Sep, 2002

Marc Logemann is founder of www.logentis.de a Java consultancy
Embed barcodes in Birt w/o barcode fonts Posted: Aug 20, 2008 8:54 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Marc Logemann.
Original Post: Embed barcodes in Birt w/o barcode fonts
Feed Title: Logemann Blog
Feed URL: http://feeds.feedburner.com/LogemannBlog
Feed Description: Marc Logemann's thoughts on java and other stuff
Latest Java Buzz Posts
Latest Java Buzz Posts by Marc Logemann
Latest Posts From Logemann Blog

Advertisement
I recently switched my report framework to Birt. Its a quite powerful framework but it doesnt have a barcode component which you can use out of the box. But if you use the Birt Runtime Engine (RE) API, you can easily create your barcode with a suitable library (like RBarcode) capable of creating barcode images and supply these "raw" images to the Birt RE.

I wont tackle the whole bootstrapping stuff of Birt, this can be researched in their docs quite easily. So lets start with


// get engine from normale Birt Bootstrapping...
// ...
design = engine.openReportDesign("/Users/reports/foo.rptdesign");
//create task to run and render report
IRunAndRenderTask task = engine.createRunAndRenderTask(design);

//set output options
PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("output/foo.pdf");
options.setOutputFormat("pdf");

task.setRenderOption(options);

// bos is a ByteOutputStream containing the
// raw image from a barcode library
byte[] bytes = bos.toByteArray();
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 byteArray 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 it. If everything worked fine, the dialogs should look like below. When you now run your report the barcode should be visible where you placed the image container.



Read: Embed barcodes in Birt w/o barcode fonts

Topic: It's Not Peculiar Previous Topic   Next Topic Topic: Hazelcast 1.1 released: Http Session clustering and more

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use