Java Barcode Generator, .NET Barcode Generator for C#, ASP.NET, VB.NET
HOME PURCHASE SITEMAP COMPANY
BarcodeLib.com Home > Products > Java Barcode > Java Barcode Jasper Reports


How to Insert Barcode Images into Jasper Reports using Barcode for Java?



FIRST Commercial Java Barcode Library Supports Jasper Reports

Quick Navigate
* We are using jasperreports-2.0.2.jar to test our Barcode for Java library.
If developer can find any problem with previous version of JasperReports, please send email to support@barcodelib.com.
  • Import class com.barcodelib.barcode.BarcodeJasperFactory into your Jasper Reports report file.
    <import value="com.barcodelib.barcode.BarcodeJasperFactory"/> 
    
  • Insert barcode image into the right place in your report.
    <image scaleImage="Clip" hAlign="Center"> 
        <reportElement x="50" y="110" width="515" height="120"/> 
        <graphicElement/> 
        <imageExpression class="net.sf.jasperreports.engine.JRRenderable">
    <![CDATA[new com.barcodelib.barcode.BarcodeJasperRenderer(BarcodeJasperFactory.createLinear(13, "0470821632"))]]></imageExpression> </image>
  • You can use method BarcodeFactory.createLinear(), or BarcodeFactory.createDataMatrix() to customize your barcode settings.
    Click to view the source code of class BarcodeJasperFactory
    If current methods in class BarcodeFactory cannot meet your requirements, you can extend class BarcodeFactory and add your own methods.
5     
6        <field name="id" class="java.lang.String"> 
7            <fieldDescription>id</fieldDescription> 
8        </field> 
9        <field name="client" class="java.lang.String"> 
10           <fieldDescription>client</fieldDescription> 
11       </field> 
12    


<image scaleImage="Clip" hAlign="Center"> 
    <reportElement x="50" y="110" width="515" height="120"/> 
    <graphicElement/> 
    <imageExpression class="net.sf.jasperreports.engine.JRRenderable">
<![CDATA[new com.barcodelib.barcode.BarcodeJasperRenderer(BarcodeJasperFactory.createLinear(22, $F{id}))]]></imageExpression> </image>