Thai characters not displaying in PDF generated from Excel in

Hello,


We are using Aspose.Cells 7.4.2
We are generating an Excel file containing one worksheet with a table and another worksheet with a chart.
In the data we are displaying some rows using thai characters.

After we have the Excel file, we are generating a PDF out of it by using this piece of code:

Workbook ws = new Workbook(new FileStream(“c:\Thai Source.xlsx”, FileMode.Open));
var saveOptions = new PdfSaveOptions(SaveFormat.Pdf) { OnePagePerSheet = true };
ws.Save(“c:\Thai-Output.pdf”, saveOptions);

The issue is that depending on where we run the code we get block characters replacing the thai ones.
For example we tried it on several webservers in our company and in some webservers we could get thai characters and in the other servers the PDF had blocks replacing thai chars.
Also on developer machines we can generate valid PDFs with thai chars.
Also another strange things is that you can see that the issue is in the “table” part of the PDF, the chart view is showing thai characters ALWAYS.
I dont know if this is making the difference, but the webservers that do not generate valid thai characters on table do not have MS Excel installed on it.

I’m attaching the source Excel and outputs.

I tried already several things found in other posts, like DefaultFont in the options using the MingLiU, setting font directory but nothing worked so far.

I hope somebody can help us here

Hi,


I have tested your scenario/ case using your template file, it works fine. The Thai chars are rendered fine in output PDF file as per the original Excel file. Well, it is surely a fonts related issue. Please make sure that the relevant fonts are installed on the systems (where you find it does not render fine) and also please try to specify the fonts directory path at first before rendering to PDF in your codes, see the line of code:
e.g
Sample code:

CellsHelper.FontDir = stringPath;
Workbook book = new Workbook(stringFile);
PdfSaveOptions pso = new PdfSaveOptions();
book.Save(outPdfFile, pso);

Also, please make sure that Aspose.Cells could access your underlying fonts directory ( assign proper rights etc.), you should confirm this on your web servers or other machines. The best way to cope with is to create a fonts folder on some path, copy all the fonts or relevant fonts from your working machine OS (e.g Windows 7/8) and paste them to your web servers, now explicitly set the fonts directory in your codes before using any other Aspose.Cells APIs and then open the file to save it to PDF file format, it should work fine.

Thank you.

Hello Amjad,


Thanks fr your reply, this solved the issue.
I created a new font directory, gave permission to webapp user to access the font dir, and copied ALL fonts from machine that was working fine and now PDF is generated correctly.

Now, is there any posibility to determine what is the font that is being used by Aspose? Sicne I need to deploy this change to a customer and I cant copy the entire font files.

Thanks in advance,
Fernando

Hi,


Good to know that your issue is resolved following the suggestion for your requirements.

Well, regarding your query to determine which Thai or other fonts are needed for a template file, I am afraid, there is no such feature available, you got to evaluate by yourself which fonts are needed, so you could copy it on the specified folder accordingly. I think for Thai fonts, you should at least pick the relevant fonts used in the template file, see the document for your reference:
http://en.wikipedia.org/wiki/List_of_Microsoft_Windows_fonts

Hope, this helps a bit.

Thank you.

Hello Amjad,


I finally did a onexone test and could find that in my case it was the “Arial Unicode MS” font (ARIALUNI.TTF).
Just installing that font in the windows\fonts dir solved the issue.

Thanks for your help !!

Hi Fernando,

Thanks for your posting and using Aspose.Cells.

It is good to know that you were able to single out the font required by your file to print the Thai characters properly. Mostly, this is the font used to display Asian characters. Let us know if you encounter any other issue, we will be glad to look into it and help you further.