Hi All,
I'm using jasper 0.6.0 version and itext 1.0.1. I'm using MS Mincho jar file and itextasian and itextasiancmaps jar file. it is printing japanese characetrs as ??? in PDF
Later i upgraded the Jasper version to 6.0.0 and itext version to 5.50 still it is printing as ???
i've attached the Java Source code and jrxml. is there a problem with my jrxml or do i need some other jars to support these characters on PDF
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <!--<!DOCTYPE jasperReport SYSTEM "D:\utilities\JasperReports\dtd\jasperreport.dtd">--> <jasperReport name="Roster" columnCount="1" printOrder="Vertical" pageWidth="635" pageHeight="842" columnWidth="270" columnSpacing="15" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" isTitleNewPage="false" isSummaryNewPage="false"> <reportFont name="Arial_Normal" isDefault="true" fontName="MS Mincho" size="10" pdfFontName="Helvetica" pdfEncoding="UTF-8" isPdfEmbedded="true"/> <reportFont name="Arial_Bold" isDefault="true" fontName="Arial" size="10" pdfFontName="Helvetica" pdfEncoding="UTF-8" isPdfEmbedded="true" isBold="true"/> <reportFont name="MS Mincho" isDefault="true" fontName="MS Mincho" size="10" pdfFontName="MS Mincho" pdfEncoding="Identity-H" isPdfEmbedded="true"/> <parameter name="TestDate" class="java.lang.String"/> <parameter name="TestCenter" class="java.lang.String"/> <parameter name="Session" class="java.lang.String"/> <parameter name="SessionId" class="java.lang.Integer"/> <parameter name="ProctorName" class="java.lang.String"/> <field name="ID" class="java.lang.String"/> <field name="CandidateName" class="java.lang.String"/> <field name="TestPortion" class="java.lang.String"/> <field name="SeatNo" class="java.lang.String"/> <field name="TestForm" class="java.lang.String"/> <field name="PaperAndPencil" class="java.lang.String"/> <field name="ExtendedTime" class="java.lang.Integer"/> <field name="CreditCardNumberString" class="java.lang.String"/> <field name="AmountPaidAndDateOfPaymentString" class="java.lang.String"/> <field name="AllCreditsFinalMessageString" class="java.lang.String"/> <field name="IAgreeToPayMessageString" class="java.lang.String"/> <field name="SessionId" class="java.lang.Integer"/> <variable name="ExamPortionsStr" class="java.lang.String" resetType="None" calculation="Nothing"> <variableExpression>"Exam Portion(s)"</variableExpression> <initialValueExpression>"Exam Portion(s)"</initialValueExpression> </variable> <group name="Candidate" minHeightToStartNewPage="200"> <groupExpression>121</groupExpression> <groupHeader> <band/> </groupHeader> <groupFooter> <band height="125"> <line> <reportElement x="0" y="110" width="595" height="0" forecolor="#999999" positionType="Float"/> <graphicElement stretchType="NoStretch" pen="Thin"/> </line> </band> </groupFooter> </group> <title> <band height="43"> <staticText> <reportElement x="0" y="0" width="595" height="23"/> <textElement textAlignment="Center"> <font reportFont="Arial_Bold" size="15"/> </textElement> <text>PSI EXAMINATION SERVICES</text> </staticText> <staticText> <reportElement x="0" y="25" width="595" height="15"/> <textElement textAlignment="Center"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>Examination Roster</text> </staticText> <line> <reportElement x="0" y="40" width="595" height="0" forecolor="#000000"/> <graphicElement stretchType="NoStretch"/> </line> </band> </title> <pageHeader> <band height="40"> <textField> <reportElement x="0" y="0" width="200" height="12"/> <textElement textAlignment="Left"> <font size="10"/> </textElement> <textFieldExpression class="java.lang.String">"Test Date : 05/04/2016" </textFieldExpression> </textField> <textField> <reportElement x="390" y="0" width="200" height="12"/> <textElement textAlignment="Right"> <font size="10"/> </textElement> <textFieldExpression class="java.lang.String">"Proctor : Ganesh "</textFieldExpression> </textField> <textField> <reportElement x="0" y="17" width="200" height="12"/> <textElement textAlignment="Left"> <font size="10"/> </textElement> <textFieldExpression class="java.lang.String">"Session : Morning "</textFieldExpression> </textField> <textField> <reportElement x="200" y="17" width="200" height="12"/> <textElement textAlignment="Left"> <font size="10"/> </textElement> <textFieldExpression class="java.lang.String">"Session # : 1 " </textFieldExpression> </textField> <textField> <reportElement x="390" y="17" width="200" height="12"/> <textElement textAlignment="Right"> <font size="10"/> </textElement> <textFieldExpression class="java.lang.String">"Test Center : Akron " </textFieldExpression> </textField> </band> </pageHeader> <columnHeader> <band height="20"> <rectangle> <reportElement x="0" y="0" width="595" height="15" backcolor="#555555"/> <graphicElement stretchType="NoStretch"/> </rectangle> <staticText> <reportElement x="0" y="2" width="50" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Center"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>ID</text> </staticText> <staticText> <reportElement x="55" y="0" width="100" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Center"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>Candidate Name</text> </staticText> <staticText> <reportElement x="325" y="0" width="50" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Center"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>Seat</text> </staticText> <staticText> <reportElement x="380" y="0" width="50" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Center"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>Test Form</text> </staticText> <staticText> <reportElement x="435" y="0" width="70" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Center"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>Test Mode</text> </staticText> <staticText> <reportElement x="510" y="0" width="85" height="15" forecolor="#FFFFFF"/> <textElement textAlignment="Left"> <font reportFont="Arial_Normal" size="10"/> </textElement> <text>Extended Time</text> </staticText> </band> </columnHeader> <detail> <band height="13"> <textField isStretchWithOverflow="true"> <reportElement x="0" y="0" width="65" height="10"/> <textElement textAlignment="Center"/> <textFieldExpression class="java.lang.String"> <![CDATA["1"]]> </textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement x="70" y="0" width="260" height="10" /> <textElement textAlignment="Left"> <font reportFont="MS Mincho"/> </textElement> <textFieldExpression class="java.lang.String"> "ガネーシュ" </textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement x="0" y="0" width="90" height="10" positionType="Float"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold"/> </textElement> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement x="110" y="0" width="485" height="10" positionType="Float"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold"/> </textElement> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="325" y="0" width="50" height="10"/> <textElement textAlignment="Left"> <font reportFont="Arial_Bold"/> </textElement> <textFieldExpression class="java.lang.String"> <![CDATA["10"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="380" y="0" width="50" height="10"/> <textElement textAlignment="Center"> <font reportFont="Arial_Bold"/> </textElement> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="435" y="0" width="70" height="10"/> <textElement textAlignment="Center"> <font reportFont="Arial_Bold"/> </textElement> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="510" y="0" width="85" height="10"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.Integer"> <![CDATA[10]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="0" y="0" width="180" height="10"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.String"> <![CDATA["1239384"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="0" y="0" width="300" height="10"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="0" y="0" width="300" height="10"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="0" y="0" width="400" height="10"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.String"> <![CDATA["Nothing"]]> </textFieldExpression> </textField> <staticText> <reportElement x="350" y="0" width="250" height="12"/> <textElement textAlignment="Right"> <font reportFont="Arial_Normal" size="9"/> </textElement> <text>Examinee Signature:________________________</text> </staticText> <staticText> <reportElement x="350" y="0" width="250" height="12"/> <textElement textAlignment="Right"> <font reportFont="Arial_Normal" size="9"/> </textElement> <text>Narrative/Fact Sheet:________________________</text> </staticText> <staticText> <reportElement x="350" y="0" width="250" height="12"/> <textElement textAlignment="Right"> <font reportFont="Arial_Normal" size="9"/> </textElement> <text>Proctor Verification:________________________</text> </staticText> </band> </detail> <columnFooter><band/></columnFooter> <pageFooter><band/></pageFooter> <summary><band/></summary> </jasperReport>
public class PdfFromXmlFile { public static void main(String[] args) throws JRException, IOException { // Compile jrxml file. JasperReport jasperReport = JasperCompileManager.compileReport("C:\\Users\\gbhagavath\\Downloads\\StyledTextReport/StyledTextReport2.jrxml"); // Parameters for report Map<String, Object> parameters = new HashMap<String, Object>(); // DataSource // This is simple example, no database. // then using empty datasource. JRDataSource dataSource = new JREmptyDataSource(); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters, dataSource); // Make sure the output directory exists. File outDir = new File("C:/jasperoutput"); outDir.mkdirs(); // Export to PDF. JasperExportManager.exportReportToPdfFile(jasperPrint,"C:/jasperoutput/StyledTextReport.pdf"); System.out.println("Done!"); }}
1 Answer:
Posted on April 5, 2017 at 3:53pm
You need to use Font extentions.
http://community.jaspersoft.com/wiki/custom-font-font-extension