2013-08-22 62 views
2

我尝试使用iReport生成PDF417条形码。问题是,我给条码的字符串包含“德语变音符号”,如ä,ö或ü。条形码不能编码这些变音符号。使用JasperReports生成PDF417-Barcode

这是我的模板:

<?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> 

我的问题是:如果有人知道为什么会这样或者我能做些什么来解决这个问题。

回答

1

将com.barcodelib.barcode.BarcodeJasperFactory类导入到您的Jasper Rep或报告文件。

<import value="com.barcodelib.barcode.BarcodeJasperFactory"/> 

将条形码图像插入报表中的正确位置。

<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> 

查看更多:how to use bar code in jasper reports in java

相关问题