Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper Reports - Custom Barcode Generation

Libraries/Tools used: 1) Jasper Reports 2) iReport 3) Java

I've already generated some standard barcodes for my reports, but this time, I'm trying to generate a custom barcode, for which I've a font file custom-barcode.ttf. As of now, iReport supports 2 barcode libraries - Barcode4j and Barbecue, which don't support the custom barcode that I need. Any ideas to get started, without much overhead of using some new library (I'm using Barcode4j already)?

BTW, I'm aware that a similar question (custom barcode font) exists on this site already.

like image 365
bchetty Avatar asked Jan 17 '12 12:01

bchetty


People also ask

Is Jaspersoft reports free for commercial use?

JasperReports Server Professional Edition is a commercially licensed reporting and analysis server based on JasperReports Server Community Edition. It is "visible" source - code comes with Professional Edition, but it is not free.

What is Barcode4J?

Barcode4J is a flexible generator for barcodes written in Java. It's free, available under the Apache License, version 2.0.


1 Answers

Just tried @mdahlman's answer and it worked. I generated the value "CODE123" using a barcode39 font (free) and Jaspersoft Barbecue. Sample Barcode

Setting the size is not very easy using the font but the result is the same. I verified the barcode using Barcode Scanner on my Android phone (can see it's visually similar too). The reason this worked for me, probably same reason @bchetty's test didn't work, is because Barcode39 doesn't have a check-digit. It is a 1-to-1 translation except with a leading and trailing asterisk (*) appended to the data. If you want to use a ttf to generate a barcode type that has a check-digit you'll need a function (external jar like you mentioned) to encode it. Barcode39 doesn't need a function since it's just "*" + V${data} + "*".

like image 185
user845279 Avatar answered Sep 18 '22 13:09

user845279