Unicode not visible in generated PDF file

Hi guys, I am using Sylfaen font and Georgian characters in my document. I've written some java code to export PDF file using *.jrxml file, but the pdf is not showing Georgian characters. I've used Font Extensions for Jasper: exported Sylfaen font in *.jar file and used it with my code, but now help at all. The exporter of Jasper Studio doesn't show characters either. What should I do?

I've specified the font export as this:

I think there is a problem with encoding but I don't know which encoding to use for Sylfaen and Georgian characters. Or there might be some other problem. I've searched everywhere and there was no solution for this.

Here is my code:

public class JasperReportMaker
{
    public static void main(String[] args) throws Exception
    {
        // Parameters
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("firstname", "ვახტანგი");
        data.put("lastname", "ლალუაშვილი");
 
        try (InputStream imageIs = JasperReportMaker.class.getResourceAsStream("/asteroids.jpg");)
        {
            byte[] byteArray = IOUtils.toByteArray(imageIs);
            String encodeToString = Base64.getEncoder().encodeToString(byteArray);
            data.put("image", encodeToString); // Save image as base64 parameter
            System.out.println(encodeToString);
        }
 
        InputStream is = JasperReportMaker.class.getResourceAsStream("/Blank_A4.jrxml");
 
        // Dummy datasource
        JRDataSource dataSource = new JREmptyDataSource();
 
        JasperReport jasperReport = JasperCompileManager.compileReport(is);
 
        JasperPrint jp = JasperFillManager.fillReport(jasperReport, data, dataSource);
 
        // Save reports
        JasperExportManager.exportReportToPdfStream(jp, new FileOutputStream("jasper-report.pdf"));
        // JasperExportManager.exportReportToPdfFile(jp, "jasper-report.pdf");
        JasperExportManager.exportReportToHtmlFile(jp, "jasper-report.html");
    }
}

vakho10's picture
Joined: Feb 5 2018 - 1:18am
Last seen: 2 years 4 weeks ago

2 Answers:

Not sure why characters are not showing up in Jaspersoft Studio.

Most of the time, I use "Identity-h(Unicode with horizontal writing)" as PDF Encoding. Not very sure but may be worth a try.

hozawa's picture
170493
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 9 months ago

This is often a problem with the PDF not being able to locate the font jar.  It must be added to the report as a resource before you export the PDF.  

https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-u...

look at the section "Deploying Font Extensions to JasperReports Server" to see how this works with JRS.

"When use font extensions in a report, the font extensions are not automatically available on the server. You need to export your font extensions as a jar and upload them to the server. For reports in HTML, add the jar to the server classpath and enable font support in jasperreports.properties. For reports in PDF, add the jar to the report as a resource."

 

elizam's picture
13994
Joined: Mar 5 2012 - 9:19am
Last seen: 2 years 7 months ago
Feedback