Barcode4J forecolor (jasper reports 5.5.1)


Hello everyone,

I need to be able to generate an Barcode4J EAN13 or Code128 code bar with a certain color (forecolor). I have tried something like this:

    <reportElement mode="Transparent" x="5" y="22" width="27" height="85" forecolor="#FF0033" uuid="5e10e200-d625-4d8e-8d7d-163136972d95">
    <jr:EAN13 xmlns:jr="" xsi:schemaLocation="" orientation="90" textPosition="bottom">

But (jasper reports 5.5.1) does not generate the bar code in the indicated color [forecolor="#FF0033"], but in black. Does anyone know if it is possible to generate color barcodes with Barcode4J and how it could be done?

It would be something similar to writing a certain arbitrary text in a certain color.

Thank you!

pgibeas's picture
Joined: Oct 15 2019 - 3:08am
Last seen: 3 weeks 6 days ago

1 Answer:


I just would try to wrap the Barbecue/Barcode4J rendering into an own ToolsClass e.g."MyColorBarcodeProducer"  and use the public API of both barcode libraries to render the image by your own color (that you perhaps also could pass as a simple String parameter to the wrapper method)

As ImageExpression you could then use something like this:

MyColorBarcodeProducer.renderEAN13($F{TheBarcodeContentFromYourField}, "red")

The method just returns the image as PNG/SVG and Jasper renders it.

hth + regards


C-Box's picture
Joined: Jul 19 2006 - 5:58pm
Last seen: 19 hours 24 min ago