Jump to content
We've recently updated our Privacy Statement, available here ×

Chinese problem (Discard prev message)


Recommended Posts

By: Joseph Wu - thwu

Chinese problem (Discard prev message)

2002-08-12 01:21

JasperReport is great report tool. But I found that it can not print and show Chinese and Japanese through JasperViewer. But it can generate pdf with

Chinese and Japanese.

 

Below is a test sample for Traditional Chinese (CHT), Simpilfied Chinese (CHS) and Japanese (JP)which modified from unicode sample.

 

Testing steps:

1. copy SYSTEMFontsKaiu.ttf to demosamplesunicode

2. replace original UnicodeReport.xml with below modified one.

3. replace original UnicodeApp.java with below modified one.

 

It shows that JasperViewer (ant view) can dsiplay CHT, but can not display CHS and JP correctly under JasperReports-0.3.3 with iText-0.93b. If you click "print", the CHT fonts are a mass. However,

if you use "ant pdf", the generated pdf can show CHT, CHS and JP correctly!

 

Hope someone can fix this.

 

------------------

UnicodeReport.xml

------------------

<?xml version="1.0"?>

<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

 

<jasperReport

name="UnicodeReport"

pageWidth="595"

pageHeight="842"

columnWidth="555"

leftMargin="20"

rightMargin="20"

topMargin="30"

bottomMargin="30">

<parameter name="SJISText" class="java.lang.String"/>

<parameter name="CHTText" class="java.lang.String"/>

<parameter name="CHSText" class="java.lang.String"/>

<parameter name="GreekText" class="java.lang.String"/>

<parameter name="CyrillicText" class="java.lang.String"/>

<title>

<band height="782">

<textField>

<reportElement x="0" y="0" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" pdfFontName="ARIAL.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="0" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="50" width="200" height="90"/><textElement><font fontName="Arial" size="14" pdfFontName="ARIAL.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="100" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" isBold="true" pdfFontName="ARIALBD.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="100" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="150" width="200" height="90"/><textElement><font fontName="Arial" size="14" isBold="true" pdfFontName="ARIALBD.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="200" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" isItalic="true" isUnderline="true" pdfFontName="ARIALI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="200" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="250" width="200" height="90"/><textElement><font fontName="Arial" size="14" isItalic="true" isUnderline="true" pdfFontName="ARIALI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="300" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" isBold="true" isItalic="true" isUnderline="true" pdfFontName="ARIALBI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="300" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="350" width="200" height="90"/><textElement><font fontName="Arial" size="14" isBold="true" isItalic="true" isUnderline="true" pdfFontName="ARIALBI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="400" width="200" height="90"/>

<textElement>

<font fontName="u5b8bu4f53" size="14" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression>$P{CHSText} + " " + $P{CHSText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="400" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="450" width="200" height="90"/><textElement>

<font fontName="u5b8bu4f53" size="14" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="false"/></textElement><textFieldExpression>$P{CHSText} + " " + $P{CHSText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="500" width="200" height="90"/>

<textElement>

<font fontName="sansserif" size="14" pdfFontName="kaiu.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="500" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="500" width="200" height="90"/>

<textElement>

<font fontName="sansserif" size="14" pdfFontName="kaiu.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="600" width="200" height="90"/>

<textElement>

<font fontName="monospaced" size="14" pdfFontName="MHei-Medium" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="600" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="600" width="200" height="90"/>

<textElement>

<font fontName="monospaced" size="14" pdfFontName="MHei-Medium" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="false"/></textElement><textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="700" width="200" height="90"/>

<textElement>

<font fontName="uff2duff33 u30b4u30b7u30c3u30af" size="14" pdfFontName="HeiseiKakuGo-W5" pdfEncoding="UniJIS-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression>$P{SJISText} + " " + $P{SJISText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="700" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="700" width="200" height="90"/><textElement><font fontName="uff2duff33 u30b4u30b7u30c3u30af" size="14" pdfFontName="HeiseiKakuGo-W5" pdfEncoding="UniJIS-UCS2-H" isPdfEmbedded="false"/></textElement><textFieldExpression>$P{SJISText} + " " + $P{SJISText}</textFieldExpression></textField>

]]></text>

</staticText>

</band>

</title>

<pageHeader>

<band height="0"/>

</pageHeader>

<columnHeader>

<band height="0"/>

</columnHeader>

<detail>

<band height="0"/>

</detail>

<columnFooter>

<band height="0"/>

</columnFooter>

<pageFooter>

<band height="0"/>

</pageFooter>

<summary>

<band height="0"/>

</summary>

</jasperReport>

 

 

 

----------------

UnciodeApp.java

----------------

/*

* JasperReports - Free Java report-generating library.

* Copyright © 2001-2002 Teodor Danciu teodord@hotmail.com

*

* This library is free software; you can redistribute it and/or

* modify it under the terms of the GNU Lesser General Public

* License as published by the Free Software Foundation; either

* version 2.1 of the License, or (at your option) any later version.

*

* This library is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

* Lesser General Public License for more details.

*

* You should have received a copy of the GNU Lesser General Public

* License along with this library; if not, write to the Free Software

* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

*

* Teodor Danciu

* 173, Calea Calarasilor, Bl. 42, Sc. 1, Ap. 18

* Postal code 741181, Sector 3

* Bucharest, ROMANIA

* Email: teodord@hotmail.com

*/

import dori.jasper.engine.*;

import dori.jasper.view.*;

import java.util.*;

 

 

/**

*

*/

public class UnicodeApp

{

 

 

/**

*

*/

private static final String TASK_COMPILE = "compile";

private static final String TASK_FILL = "fill";

private static final String TASK_PRINT = "print";

private static final String TASK_PDF = "pdf";

private static final String TASK_XML = "xml";

private static final String TASK_XML_EMBED = "xmlEmbed";

private static final String TASK_RUN = "run";

 

 

/**

*

*/

public static void main(String[] args)

{

String fileName = null;

String taskName = null;

 

if(args.length == 0)

{

usage();

return;

}

 

int k = 0;

while ( args.length > k )

{

if ( args[k].startsWith("-T") )

taskName = args[k].substring(2);

if ( args[k].startsWith("-F") )

fileName = args[k].substring(2);

 

k++;

}

 

try

{

long start = System.currentTimeMillis();

if (TASK_COMPILE.equals(taskName))

{

JasperCompileManager.compileReportToFile(fileName);

System.err.println("Compile time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_FILL.equals(taskName))

{

Map parameters = new HashMap();

parameters.put("SJISText", "u7b39u8fbc");

parameters.put("CHTText", "u6e2cu8a66");

parameters.put("CHSText", "u53d6u6e96u53d7u4fddu4ebau5728u6211u56fdu7ecfu6d4eu7ed3u6784");

parameters.put("GreekText", "u0393u0394u0398u039Bu039Eu03A0u03A3u03A6u03A8u03A9");

parameters.put("CyrillicText", "u0402u040Bu040Fu0414u0416u0418u041Bu0426u0429u042E");

 

JasperFillManager.fillReportToFile(fileName, parameters, new JREmptyDataSource());

System.err.println("Filling time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_PRINT.equals(taskName))

{

JasperPrintManager.printReport(fileName, true);

System.err.println("Printing time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_PDF.equals(taskName))

{

JasperPrintManager.printReportToPdfFile(fileName);

System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_XML.equals(taskName))

{

JasperPrintManager.printReportToXmlFile(fileName, false);

System.err.println("XML creation time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_XML_EMBED.equals(taskName))

{

JasperPrintManager.printReportToXmlFile(fileName, true);

System.err.println("XML creation time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_RUN.equals(taskName))

{

Map parameters = new HashMap();

parameters.put("SJISText", "u0041u7b39u8fbc");

parameters.put("CHTText", "u6e2cu8a66");

parameters.put("CHSText", "u53d6u6e96u53d7u4fddu4ebau5728u6211u56fdu7ecfu6d4eu7ed3u6784");

parameters.put("GreekText", "u0393u0394u0398u039Bu039Eu03A0u03A3u03A6u03A8u03A9");

parameters.put("CyrillicText", "u0402u040Bu040Fu0414u0416u0418u041Bu0426u0429u042E");

 

JasperRunManager.runReportToPdfFile(fileName, parameters, new JREmptyDataSource());

System.err.println("PDF running time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else

{

usage();

System.exit(0);

}

}

catch (JRException e)

{

e.printStackTrace();

System.exit(1);

}

catch (Exception e)

{

e.printStackTrace();

System.exit(1);

}

}

 

 

/**

*

*/

private static void usage()

{

System.out.println( "UnicodeApp usage:" );

System.out.println( "tjava UnicodeApp -Ttask -Ffile" );

System.out.println( "tTasks : compile | fill | print | pdf | xml | xmlEmbed | run" );

}

 

 

}

 

 

 

By: Teodor Danciu - teodord

RE: Chinese problem (Discard prev message)

2002-08-12 01:39

 

Hi,

 

"Discard prev message".

Does it mean that everything is OK for you now ?

 

Thank you,

Teodor

 

 

 

By: Joseph Wu - thwu

RE: Chinese problem (Discard prev message)

2002-08-12 04:18

Yes, after a little modification of UnicodeReport.xml, everything works now :-)

 

The fontName should be "SimSun", "MS UI Gothic", "MS Gothic", etc for correct display and printing. Do not use "Monospaced" or "SansSerif" for Chinese and Japanese, because printing will be a block or a mass.

 

For Traditional-Chinese

<font fontName="SimSun" size="14" pdfFontName="MHei-Medium" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="false"/>

 

For Simpilfied-Chinese

<font fontName="SimSun" size="14" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="false"/>

 

For Japanese

<font fontName="MS UI Gothic" size="14" pdfFontName="HeiseiKakuGo-W5" pdfEncoding="UniJIS-UCS2-H" isPdfEmbedded="false"/>

 

Below is tested-and-work sample codes (JasperReport-0.3.3 + iText-0.93b) , I suggest Teodor use these to replace original unicode sample code.

 

Joseph Wu

 

-------------------------

UnicodeApp.java

-------------------------

/*

* JasperReports - Free Java report-generating library.

* Copyright © 2001-2002 Teodor Danciu teodord@hotmail.com

*

* This library is free software; you can redistribute it and/or

* modify it under the terms of the GNU Lesser General Public

* License as published by the Free Software Foundation; either

* version 2.1 of the License, or (at your option) any later version.

*

* This library is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

* Lesser General Public License for more details.

*

* You should have received a copy of the GNU Lesser General Public

* License along with this library; if not, write to the Free Software

* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

*

* Teodor Danciu

* 173, Calea Calarasilor, Bl. 42, Sc. 1, Ap. 18

* Postal code 741181, Sector 3

* Bucharest, ROMANIA

* Email: teodord@hotmail.com

*/

import dori.jasper.engine.*;

import dori.jasper.view.*;

import java.util.*;

 

 

/**

*

*/

public class UnicodeApp

{

 

 

/**

*

*/

private static final String TASK_COMPILE = "compile";

private static final String TASK_FILL = "fill";

private static final String TASK_PRINT = "print";

private static final String TASK_PDF = "pdf";

private static final String TASK_XML = "xml";

private static final String TASK_XML_EMBED = "xmlEmbed";

private static final String TASK_RUN = "run";

 

 

/**

*

*/

public static void main(String[] args)

{

String fileName = null;

String taskName = null;

 

if(args.length == 0)

{

usage();

return;

}

 

int k = 0;

while ( args.length > k )

{

if ( args[k].startsWith("-T") )

taskName = args[k].substring(2);

if ( args[k].startsWith("-F") )

fileName = args[k].substring(2);

 

k++;

}

 

try

{

long start = System.currentTimeMillis();

if (TASK_COMPILE.equals(taskName))

{

JasperCompileManager.compileReportToFile(fileName);

System.err.println("Compile time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_FILL.equals(taskName))

{

Map parameters = new HashMap();

parameters.put("SJISText", "u7b39u8fbc");

parameters.put("CHTText", "u6e2cu8a66u770bu662fu5426u503cu5f97u4e2du9593u6bb5u843d");

parameters.put("CHSText", "u53d6u6e96u53d7u4fddu4ebau5728u6211u56fdu7ecfu6d4eu7ed3u6784u7279u8fdfu8d44");

parameters.put("GreekText", "u0393u0394u0398u039Bu039Eu03A0u03A3u03A6u03A8u03A9");

parameters.put("CyrillicText", "u0402u040Bu040Fu0414u0416u0418u041Bu0426u0429u042E");

 

JasperFillManager.fillReportToFile(fileName, parameters, new JREmptyDataSource());

System.err.println("Filling time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_PRINT.equals(taskName))

{

JasperPrintManager.printReport(fileName, true);

System.err.println("Printing time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_PDF.equals(taskName))

{

JasperPrintManager.printReportToPdfFile(fileName);

System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_XML.equals(taskName))

{

JasperPrintManager.printReportToXmlFile(fileName, false);

System.err.println("XML creation time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_XML_EMBED.equals(taskName))

{

JasperPrintManager.printReportToXmlFile(fileName, true);

System.err.println("XML creation time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else if (TASK_RUN.equals(taskName))

{

Map parameters = new HashMap();

parameters.put("SJISText", "u0041u7b39u8fbc");

parameters.put("CHTText", "u6e2cu8a66");

parameters.put("CHSText", "u53d6u6e96u53d7u4fddu4ebau5728u6211u56fdu7ecfu6d4eu7ed3u6784");

parameters.put("GreekText", "u0393u0394u0398u039Bu039Eu03A0u03A3u03A6u03A8u03A9");

parameters.put("CyrillicText", "u0402u040Bu040Fu0414u0416u0418u041Bu0426u0429u042E");

 

JasperRunManager.runReportToPdfFile(fileName, parameters, new JREmptyDataSource());

System.err.println("PDF running time : " + (System.currentTimeMillis() - start));

System.exit(0);

}

else

{

usage();

System.exit(0);

}

}

catch (JRException e)

{

e.printStackTrace();

System.exit(1);

}

catch (Exception e)

{

e.printStackTrace();

System.exit(1);

}

}

 

 

/**

*

*/

private static void usage()

{

System.out.println( "UnicodeApp usage:" );

System.out.println( "tjava UnicodeApp -Ttask -Ffile" );

System.out.println( "tTasks : compile | fill | print | pdf | xml | xmlEmbed | run" );

}

 

 

}

 

 

-----------------------------

UnicodeReport.xml

-----------------------------

<?xml version="1.0"?>

<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

 

<jasperReport

name="UnicodeReport"

pageWidth="595"

pageHeight="842"

columnWidth="555"

leftMargin="20"

rightMargin="20"

topMargin="30"

bottomMargin="30">

<parameter name="SJISText" class="java.lang.String"/>

<parameter name="CHTText" class="java.lang.String"/>

<parameter name="CHSText" class="java.lang.String"/>

<parameter name="GreekText" class="java.lang.String"/>

<parameter name="CyrillicText" class="java.lang.String"/>

<title>

<band height="782">

<textField>

<reportElement x="0" y="0" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" pdfFontName="ARIAL.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="0" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="50" width="200" height="90"/><textElement><font fontName="Arial" size="14" pdfFontName="ARIAL.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="100" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" isBold="true" pdfFontName="ARIALBD.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="100" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="150" width="200" height="90"/><textElement><font fontName="Arial" size="14" isBold="true" pdfFontName="ARIALBD.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="200" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" isItalic="true" isUnderline="true" pdfFontName="ARIALI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="200" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="250" width="200" height="90"/><textElement><font fontName="Arial" size="14" isItalic="true" isUnderline="true" pdfFontName="ARIALI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="300" width="200" height="90"/>

<textElement>

<font fontName="Arial" size="14" isBold="true" isItalic="true" isUnderline="true" pdfFontName="ARIALBI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="300" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="350" width="200" height="90"/><textElement><font fontName="Arial" size="14" isBold="true" isItalic="true" isUnderline="true" pdfFontName="ARIALBI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{GreekText} + " " + $P{CyrillicText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="400" width="200" height="90"/>

<textElement>

<font fontName="SimSun" size="14" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression>$P{CHSText} + " " + $P{CHSText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="400" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="450" width="200" height="90"/><textElement>

<font fontName="SimSun" size="14" pdfFontName="STSong-Light" pdfEncoding="UniGB-UCS2-H" isPdfEmbedded="false"/></textElement><textFieldExpression>$P{CHSText} + " " + $P{CHSText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="500" width="200" height="90"/>

<textElement>

<font fontName="MS UI Gothic" size="14" pdfFontName="kaiu.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>

</textElement>

<textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="500" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="500" width="200" height="90"/>

<textElement>

<font fontName="MS UI Gothic" size="14" pdfFontName="kaiu.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="600" width="200" height="90"/>

<textElement>

<font fontName="SimSun" size="14" pdfFontName="MHei-Medium" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="600" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="600" width="200" height="90"/>

<textElement><font fontName="SimSun" size="14" pdfFontName="MHei-Medium" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="false"/></textElement><textFieldExpression>$P{CHTText} + " " + $P{CHTText}</textFieldExpression></textField>

]]></text>

</staticText>

 

<textField>

<reportElement x="0" y="700" width="200" height="90"/>

<textElement>

<font fontName="MS UI Gothic" size="14" pdfFontName="HeiseiKakuGo-W5" pdfEncoding="UniJIS-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression>$P{SJISText} + " " + $P{SJISText}</textFieldExpression>

</textField>

<staticText>

<reportElement x="210" y="700" width="340" height="90"/>

<text><![CDATA[

<textField><reportElement x="0" y="700" width="200" height="90"/>

<textElement><font fontName="MS UI Gothic" size="14" pdfFontName="HeiseiKakuGo-W5" pdfEncoding="UniJIS-UCS2-H" isPdfEmbedded="false"/></textElement><textFieldExpression>$P{SJISText} + " " + $P{SJISText}</textFieldExpression></textField>

]]></text>

</staticText>

</band>

</title>

<pageHeader>

<band height="0"/>

</pageHeader>

<columnHeader>

<band height="0"/>

</columnHeader>

<detail>

<band height="0"/>

</detail>

<columnFooter>

<band height="0"/>

</columnFooter>

<pageFooter>

<band height="0"/>

</pageFooter>

<summary>

<band height="0"/>

</summary>

</jasperReport>

 

 

 

 

By: Chris Beels - cbeels

RE: Chinese problem

2002-11-13 07:35

I too, have a chinese problem! Looks like more of an Itext problem than a JR issue, but since I'm using JR...No matter which Asian pdfEncoding I use, I get the following message:

 

Report LBTester JR error

com.lowagie.text.DocumentException: UniCNS-UCS2-H

at com.lowagie.text.pdf.TrueTypeFont.<init>(Unknown Source)

at com.lowagie.text.pdf.TrueTypeFont.<init>(Unknown Source)

at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)

 

Having reviewed the iText code, it seems like it should be using the CJKFont class rather than TrueType...but I can't get it to switch.

 

The text field that generates the error is

<textField isBlankWhenNull="true" isStretchWithOverflow="false" >

<reportElement x="235" y="125" width="675" height="200" forecolor="#000000">

</reportElement>

<textElement textAlignment="Left" lineSpacing="Single">

<font fontName="STSongStd-Light" size="22" pdfFontName="C:\Program Files\Adobe\Acrobat 5.0\Resource\CIDFont\STSongStd-Light-Acro.otf"

pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="false"/>

</textElement>

<textFieldExpression class="java.lang.String">

" |?[ g t H   I Ü‚  ÍŠ    Ì‘I  "

</textFieldExpression>

</textField>

 

Any ideas?

 

Thanks,

Chris

 

 

By: Paulo Soares - psoares33

RE: Chinese problem

2002-11-13 07:43

Your font name should be "STSongStd-Light". CJK otf fonts are not supported by iText.

 

 

By: Eric Tan - neltan

RE: Chinese problem (Discard prev message)

2002-11-26 19:42

Hi,

I'm now using iReport. I have 2 question.

 

1. How can I generate Chinese when they are data from database?

2. How can I get the unicode of a Chinese character?

 

Best Regards,

neltan

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...