pgibeas Posted October 15, 2019 Share Posted October 15, 2019 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:<componentElement> <reportElement mode="Transparent" x="5" y="22" width="27" height="85" forecolor="#FF0033" uuid="5e10e200-d625-4d8e-8d7d-163136972d95"> <printWhenExpression><![CDATA[$F{CODIGEAN_TYPE}.equals("EAN13")]]></printWhenExpression> </reportElement> <jr:EAN13 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" orientation="90" textPosition="bottom"> <jr:codeExpression><![CDATA[$F{CODIGEAN}]]></jr:codeExpression> </jr:EAN13></componentElement>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! Link to comment Share on other sites More sharing options...
C-Box Posted October 18, 2019 Share Posted October 18, 2019 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 + regardsC-Box Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now