I'm generating a multi-language report using JasperReports in Java.
When I generate pdf, few languages do not display properly.
Whereas, When I generate Excel, The report is generated properly with the correct language.
searching on the internet I found pdf font is not supported.
here my code set to font:
Style rowStyle = new Style();
Font font = new Font(FONT_SIZE_SMALL, "Noto Sans", false, false, false);
font.setPdfFontName("Noto Sans");
font.setPdfFontEncoding(Font.PDF_ENCODING_Identity_H_Unicode_with_horizontal_writing);
font.setPdfFontEmbedded(false);
rowStyle.setFont(font);
any idea how to solve?
Have you tried setting DEBUG jasper reports logging to check which font is getting used when the PDF is rendered? (example log4j setup below)
<category name="net.sf.jasperreports">
<priority value="DEBUG" />
</category>
For example you should see DEBUG log of a font being loaded by jasper:
DEBUG SimpleFontFace:177 - Loading font fonts/ARIALUNI.TTF
And if you are using jasper font extension (described below), you should see something like:
DEBUG FontExtensionsRegistry:88 - Loading font extensions from net/sf/jasperreports/fonts/jasperreports-fonts.xml
Are you including the font in the classpath? I have successfully used a custom built jar similar to what is described in this post in the docs: https://community.jaspersoft.com/wiki/adding-fonts-embedding-pdf
I would also try setPdfFontEmbedded(true). In the generated PDF you can determine if the font is included in the report if you open the PDF in Adobe Acrobat Reader, and see if it is listed under File -> Properties... -> Fonts tab (see screenshot). It should have (Embedded) or (Embedded subset) next to the font name.
Above steps can help debug issues like this. It turns out that the "Noto Sans" font doesn't support Indian characters, using "Arial Unicode MS" works though.
In Docs, you can see how many languages are supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With