0

I have this .jrxml file :

 <?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="multi1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c8a053f6-858e-427b-aec1-89231aadddd6">
<title>
    <band height="79" splitType="Stretch">
        <staticText>
            <reportElement x="104" y="0" width="313" height="25" uuid="fa5e3e6e-26f7-4973-a2d5-3c3b7a5e8227"/>
            <textElement textAlignment="Center">
                <font size="16" fontName="Lohit Devanagari" isPdfEmbedded="true" pdfEncoding="Identity-H" />
            </textElement>
            <text><![CDATA[अतिदेय राशि के पुनर्भुगतान हेतु अनुस्मारक]]></text>
        </staticText>
        <staticText>
            <reportElement x="132" y="25" width="252" height="25" uuid="fa5e3e6e-26f7-4973-a2d5-3c3b7a5e8227"/>
            <textElement textAlignment="Center">
                <font size="16"/>
            </textElement>
            <text><![CDATA[Reminder for repaying Overdue Amount]]></text>
        </staticText>
    </band>
</title>
</jasperReport>

When I convert this to PDF, I do not get the Hindi Text. My code for converting to pdf is as follows:

public class PdfFromXmlFile {

   public static void main(String[] args) throws JRException, IOException {

    // Compile jrxml file.
   JasperReport jasperReport = JasperCompileManager
           .compileReport("C:/report.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/report.pdf");

   System.out.println("Done!");
   }
}

How do I fix this? I tried to create a jar with Lohit-Devanagari ttf from JasperSoft Studio and imported it here but it didn't work.

S_S
  • 1,276
  • 4
  • 24
  • 47
  • Have you tried with the jar in my answer? – Petter Friberg Jun 08 '17 at 12:01
  • Hmm empty datasource also or use the whenNoData attribute or add 1 record to your empty datasource new JREmptyDataSource(1) – Petter Friberg Jun 08 '17 at 12:05
  • @Sumit do you see any text or is the report just blank?, I will suggest another duplicate if your report is blank, since it actually has nothing to do with font-extensions, language, jar etc. please let me know – Petter Friberg Jun 08 '17 at 14:34
  • I do see English text `Reminder for repaying Overdue Amount`, just the Hindi one doesn't show up. I tried an alternative using `Kruti-Dev-010` for the time being, but I would need to switch to this as I am told that is not supported by all pdf renderers. – S_S Jun 09 '17 at 09:30

0 Answers0