Reputation: 21
I try to generate a PDF417 barcode with iReport. The problem is that the String that I give the barcode contain "german umlauts" like ä,ö or ü. This umlauts can not be encode by the barcode.
This is my template:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20"
rightMargin="20" topMargin="20" bottomMargin="20">
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement positionType="Float" mode="Opaque" x="432" y="189" width="148" height="75"/>
<jr:PDF417 xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"
moduleWidth="38.0" textPosition="none" quietZone="2.0" verticalQuietZone="2.0" minColumns="7"
maxColumns="7" minRows="5" widthToHeightRatio="2.0" errorCorrectionLevel="4">
<jr:codeExpression><![CDATA["äöüÄÖÜß Test Test"]]></jr:codeExpression>
</jr:PDF417>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
My Question is: If anyone know why this happens or what I can do to fix the problem.
Upvotes: 2
Views: 2290
Reputation: 11
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>
See more: how to use bar code in jasper reports in java
Upvotes: 1
Reputation: 1745
I think you missed a '['. Try using
[!CDATA[[äöüÄÖÜß Test Test]]]
(without ")
More info here http://www.w3schools.com/xml/xml_cdata.asp
Another option could be use an image and barcode generator like showed here
Upvotes: 0