We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to PDF conversion issue with Kannada language (Indian Regional language) characters using C#

Hi Team,

Can you please confirm if Aspose Pdf can be used to generate PDF in Kannada language. I have attached an html file and added the import statements for all the fonts which are supposed to generate Kannada text. The meta charset for utf-8 is also added. Now the Aspose Pdf code ( below ) is generating the kannada text but the font syllables are not correct. You can validate this by converting it and comparingGetCaseRegistration_Kannada.zip (3.8 KB)
.

public byte[] GeneratePdf()
{
byte[] documentBytes;
using var doc = new Document();

        // Create a section in the Pdf object
        Aspose.Pdf.Page page = doc.Pages.Add();

        var htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions
        {
            InputEncoding = nameof(Encoding.UTF8),
            IsEmbedFonts = true,
        };
        var chineseFragement = new Aspose.Pdf.HtmlFragment(" The Chinese Text Project (CTP; Chinese: 中國哲學書電子化計劃) is a digital library project");
        var germanFragement = new Aspose.Pdf.Text.TextFragment("Es war ein super-schwüller Tag. Wir konnten die Hitze kaum ertragen und entschlossen ");
        germanFragement.TextState.FontSize = 8;
        germanFragement.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial Unicode MS");
        germanFragement.TextState.Font.IsEmbedded = true;
        var fragment = new Aspose.Pdf.HtmlFragment("ಜಿಲ್ಲೆ    ಪೊಲೀಸ್‌ ಠಾಣೆಯ ವಿವರಗಳು\r\nಕಾಯ್ದೆಗಳು ಮತ್ತು ಕಲಂಗಳು\r\nಕೃತ್ಯ ನಡೆದ ಸಮಯ\r\nಘಟನೆ ನಡೆದ ಸ್ಥಳ\r\nಫಿರ್ಯಾದುದಾರ/ಬಾತ್ಮೀದಾರ\r\nಆರೋಪಿಯ ವಿವರ\r\nನೋಂದವರ ವಿವರ\r\nಕಳವಾದ/ಬಾಗಿಯಾದ ಸ್ವತ್ತುಗಳ ವಿವರಗಳು\r\nಪ್ರ.ವ.ವ ಸಾರಾಂಶ\r\nತೆಗೆದುಕೊಂಡ ಕ್ರಮ\r\nಪಿರ್ಯಾದುದಾರರ ಸಹಿ\r\nನ್ಯಾಯಾಲಯಕ್ಕೆ ರವಾನೆಯಾದ ಸಮಯ\r\nನ್ಯಾಯಾಲಯಕ್ಕೆ ಪ್ರ.ವ.ವ ತೆಗೆದುಕೊಂಡು ಹೋದವರು ಹೆಚ್‌.ಸಿ/ಪಿ.ಸಿ\r\nಇತರ ವಿವರಗಳು\r\nಠಾಣಾಧಿಕಾರಿಯ ಸಹಿ");
        page.Paragraphs.Add(fragment);
        page.Paragraphs.Add(chineseFragement);
        page.Paragraphs.Add(germanFragement);

        using var documentStream = new MemoryStream();
        doc.Save(documentStream, SaveFormat.Pdf);
        documentBytes = documentStream.ToArray();
        doc.FreeMemory();

        return documentBytes;
    }

The above code is working fine for the Chinese and German language, but not converting the kannada font correctly.
Found the same issue if I am using the Aspose html to pdf online convertor tool.
Can you please validate the behavior at your end and let me know. One quick note, this testing is performed locally on the Windows system.

Regards,
Vishesh

@singhvishesh394

Please note that Aspose.PDF requires true type fonts for rendering Chinese, German, Kannada languages. You need to install fonts to render Kannada language correctly.

Can you please help me pointing out which fonts I need to install.
I tried below fonts till now:

  1. Baloo Tamma 2
  2. Tunga
  3. Nirmal
  4. Arial Unicode MS.

The pdf generated using Aspose Pdf has kannada font, but the syllables are not correct.

For ex: in the below code :
var fragment = new Aspose.Pdf.HtmlFragment(“ಜಿಲ್ಲೆ ಪೊಲೀಸ್‌ ಠಾಣೆಯ ವಿವರಗಳು\r\nಕಾಯ್ದೆಗಳು ಮತ್ತು ಕಲಂಗಳು\r\nಕೃತ್ಯ ನಡೆದ ಸಮಯ\r\nಘಟನೆ ನಡೆದ ಸ್ಥಳ\r\nಫಿರ್ಯಾದುದಾರ/ಬಾತ್ಮೀದಾರ\r\nಆರೋಪಿಯ ವಿವರ\r\nನೋಂದವರ ವಿವರ\r\nಕಳವಾದ/ಬಾಗಿಯಾದ ಸ್ವತ್ತುಗಳ ವಿವರಗಳು\r\nಪ್ರ.ವ.ವ ಸಾರಾಂಶ\r\nತೆಗೆದುಕೊಂಡ ಕ್ರಮ\r\nಪಿರ್ಯಾದುದಾರರ ಸಹಿ\r\nನ್ಯಾಯಾಲಯಕ್ಕೆ ರವಾನೆಯಾದ ಸಮಯ\r\nನ್ಯಾಯಾಲಯಕ್ಕೆ ಪ್ರ.ವ.ವ ತೆಗೆದುಕೊಂಡು ಹೋದವರು ಹೆಚ್‌.ಸಿ/ಪಿ.ಸಿ\r\nಇತರ ವಿವರಗಳು\r\nಠಾಣಾಧಿಕಾರಿಯ ಸಹಿ”);
The font you see, is for Kannada ( with the correct syllables), this is the input we are giving to the Aspose Pdf. The output we are getting from Aspose is attached here.
outputKa.pdf (414.0 KB)

Now, if you compare the syllable for both the text, you can find out, they are different. Just compare the first word in both the text.
Now, my question is Can you provide me with the correct font I should use so that I get proper text or is this a limitation of Aspose pdf.

The reason for asking this question is, even if I use a html file with charset and font specified and use the Aspose Online HTML to PDF converter, I am receiving the incorrect response ( means kannada fonts are there, but with incorrect syllables, please check the attached file for reference)

@singhvishesh394

Could you please ZIP and attach these fonts here for testing? We will investigate the issue and provide you information on it.