I am using flying saucer 9.x to generate PDFs from HTML. Indian languages like Kannada, Hindi or any other languages are not being displayed properly in the PDF.
Following is a simple html to replicate the issue.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.multiLang {
font-family: "ArialUnicodeMS", "Arial", "sans-serif", "serif";
}
</style>
</head>
<body>
<div class="multiLang">
<h1>
KA:ಸ್ವತಂತ್ರರಾಗಿ, <br />
HN:प्रत्येक व्यक्ति
</h1>
</div>
</body>
</html>
And below is the java code that is used to generate the pdf:
public byte[] generatePdf(String processedHtml) throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("/fonts/Arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.getFontResolver().addFont("/fonts/kannada.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.getFontResolver().addFont("/fonts/Kannada MN.ttc", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.getFontResolver().addFont("/fonts/Arial Unicode MS Regular.ttf", "ArialUnicodeMS", BaseFont.IDENTITY_H, true, null);
renderer.getFontResolver().addFont("/fonts/hindi.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.layout();
renderer.createPDF(os, false);
renderer.finishPDF();
return os.toByteArray();
} catch (Exception e) {
throw e;
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
/* ignore */
}
}
}
}
The text was expected to be printed like the following 
But instead, it seems like the characters are broken into individual graphemes.
I have tried adding all the necessary fonts like Kannada and Hindi fonts.
I have also tried playing around with font family in the css. But the issue still persists. How do I make it work?
