Arabic characters doesn't show properly in Android

I am trying to save a doc file to PDF in Aspose.Words for Android (Java) using:

doc.save(PDF_FILE_PATH);

RTL and all charachters are OK except the Arabic ones that show in a strange format.
I read before that I need to set the font but how to do so on the Android one and what is the easiest thing to do so? since I only want to convert the doc file to pdf with aspose.Words

@dembas,

You can copy all the required fonts from Windows to inside a directory on your device and then specify the Font Folder that Aspose.Words will use.

In case the problem still remains, please ZIP and attach your input Word document, Aspose.Words’ generated PDF file showing the undesired behavior and the font files used in Word document here for testing. We will then investigate the issue on our end and provide you more information.

Hi @awais.hafeez
I don’t know if the same can be applied to Aspose.Words for Android, If yes, what should be its default location inside the app?

I also tried and copied all windows 10 fonts (ttf) to a directory on android and set it as fonts directory but still have the same issue.

@dembas,

You can use any folder on your device for this purpose and give path inside setFontsFolder method. Make sure your app has storage read write permissions.

In case the problem still remains, please ZIP and attach your input Word document, Aspose.Words’ generated PDF file showing the undesired behavior and the font files used in Word document here for testing. We will then investigate the issue on our end and provide you more information.

If your ZIP file size is big then you can upload the ZIP file to Dropbox and share the Download link here for testing.

Hi @awais.hafeez
I putted my Times New Roman font in assets/fonts and applied the following method:

public String GenerateDocToPDF(String docPath) throws Exception {
String pdfPath = context.getCacheDir() + File.separator + Files.getNameWithoutExtension(docPath) + “.pdf”;
Document doc = new Document(docPath);
FontSettings.setFontsFolder(getActivity().getAssets() + “/fonts”, false);
FontSettings.setDefaultFontName(“Times New Roman”);
doc.save(pdfPath);
return pdfPath;
}

It works for English characters but not for Arabic one and also the character “Ş” shows as following image:
Screenshot_1548334521.jpg (177.4 KB)

@dembas,

Please use the code from the following article to know what missing fonts you actually need to copy to your Android device.
How to Receive Notification of Missing Fonts and Font Substitution during Rendering

1 Like

Thank you so much, it works now

@dembas,

It is great that you were able to resolve this issue on your end. Please let us know anytime you have any further queries.