Convert Excel To Pdf Encoding Issue

I’m using Aspose JAVA in order to converts Word,PPT and Excel files to .pdf format.

The files are written Hebrew and English.
So far, converting Word and PPT works just fine for both Hebrew and English.
The problem comes up when I’m trying to convert Excel file to pdf , since the output contains gibberish characters.
An example is added - an Excel file which contains Hebrew characters , and the pdf output file which does not contain any Hebrew character at all.
I’d be grateful if anyone could point me to the solution.

Thanks in advnace,
Itamar.

Hi Itamar,


Thank you for contacting Aspose support.

We have evaluated your presented scenario on our end, and it seems that the problem is related to the missing required fonts in the environment where conversion is taking place. In order to troubleshoot the problem on your side, please confirm that the required font (DejaVu Sans) is available in your environment. In case the font is available, please use the CellsHelper.setFontDir method to point the Aspose.Cells for Java API to the fonts location. Please note, the CellsHelper.setFontDir method should be at the start of your application.

For better elaboration on how Aspose.Cells for Java uses TrueType Fonts( TTFs), please go through the following articles.

In case the problem persists, please share your environment details such as Operation System version/architecture, JDK version etc, so we may simulate the environment to replicate the issue.

Hey Babar,

first of all - thanks for the quick reply.
I’ve followed the steps mentioned in your post , and I’m still getting the same output.
I’d like to solve this issue as soon as possible, and I’d be thankful if you’d suggest another solution.
Thanks in advance.

Hi Itamar,


We are sorry to know that the previous discussion didn’t help.

We have re-evaluated the presented scenario, and we still think the problem is related to the missing fonts. Please check the attached PDF file that we have generated on Windows 7 Home Premium 64-bit with JDK 1.7. You will notice that the characters have been rendered correctly. Please also check the attached snapshot showing the embedded fonts in the PDF file.

The spreadsheet shared earlier uses three fonts as listed below. When you place these fonts in your environment, and call the CellsHelper.setFontDir method specifying the correct location to the fonts, the PDF rendering engine will embed these fonts in the PDF.

Please download these fonts from above links, and place them in your environment to reevaluate the scenario on your side. Please note, the fonts have been taken from a Windows environment so if you wish to use these fonts in production on a platform other than Windows, you have to check the licensing information from their vendor(s).

In case the problem persists, please provide us the environment details so we may simulate it to replicate the problem on our end.

Thanks for helping me resolve the problem.


It works just fine for Windows, but it still does not work at all at linux, which is the OS where my application is running on.
I’d be grateful if you’ve got any Linux-targeted solution,
Thanks in advance.

Hi Itamar,


We are sorry to know that you are still experiencing the problem.

Please note, in order to avoid the said problem (regardless of the platform), the key is to place the required fonts in any accessible directory and tell the API to look for the fonts at that location. Most importantly, you have to call the CellsHelper.setFontDir method before executing the conversion process.

We are moving forward to test the case on our end with most readily available Linux distribution (Ubuntu) against the latest version of Aspose.Cells for Java 8.2.0.1, and we will keep you posted with updates in this regard. In the meanwhile, we would request you to please give a try to the latest build (link shared above). In case the problem persists, please provide the following information for thorough analysis.

  • Operating System version
  • Operating System architecture (32-bit/64-bit)
  • JDK Type (OpenJDK/Sun) & version
  • List of available fonts in your environment
  • PDF generated on your end
  • Template spreadsheet, if it is different than what you have already shared

Thank you for your continues support in figuring out this issue.

Hi Itamar,


Just to keep you informed that we have performed a few tests on Ubuntu 12 LTS (64 bit) with OpenJDK 1.7.0_65 against your provided spreadsheet. Unfortunately, we are unable to replicate the problem on our end by setting the font’s location before executing the conversion process. In order to look further into this matter, we need your environment details as requested in previous response.

Thanks for your reply, here are the details you need :


-Operating system version : Ubuntu quantal , 12.10

-Operating system architecture : 64 bit

-JDK Type : OpenJDK 1.7.0_07

-List of available fonts :
abyssinica kacst padauk ttf-dejavu
ariel kacst-one sinhala ttf-indic-fonts-core
DejaVuSans lao tahoma ttf-khmeros-core
fonts-japanese-gothic.ttf liberation takao-gothic ttf-punjabi-fonts
fonts-sil-abyssinica nanum tibetan-machine ubuntu-font-family
freefont openoffice tlwg wqy


-PDF generated is attached

-Template spreadsheet : I didn’t change the spreadsheet template, i.e - it’s the default one

Moreover , i’d like to add the code i’m using in order to convert the file :

com.aspose.cells.CellsHelper.setFontDir(“truetype”);
File folder = new File(“truetype”);
Workbook wb = new Workbook(sourceAddr);
wb.save(destAddr,com.aspose.cells.SaveFormat.PDF);


Thanks in advance !

Hi Itamar,


Thank you for providing the details. The environment settings are almost the same on which we have performed the previous testing. We will do that again, and get back to you with updates in this regard.

By looking at your provided code snippet, I have one concern regarding the CellsHelper.setFontDir method. You are passing the string “truetype” as a parameter, whereas the location to the fonts should be passed as elaborated below.

Java

CellsHelper.setFontDir("/home/babar/Downloads/fonts");

Could you please explain, how are you using the said method in your application?

Hi Itamar,


We have thoroughly tested the case on Ubuntu 12 TLS with OpenJDK 1.7.0_65 by placing the required fonts (as shared earlier) on the machine, and by generating the PDF as follow. Please note, we have used the Aspose.Cells for Java 8.2.0.1 (shared earlier in this thread).

Java

ArrayList fontsDirs = new ArrayList();
fontsDirs.add("/home/babar/Downloads/ariel");
fontsDirs.add("/home/babar/Downloads/tahoma");
fontsDirs.add("/home/babar/Downloads/DejaVuSans");
CellsHelper.setFontDirs(fontsDirs);

Workbook book = new Workbook(input);
book.save(outputPdf, SaveFormat.PDF);

You will observe from the resultant PDF file (attached) that the characters are rendered fine, also the PDF file contains the correct set of embedded fonts. We are now certain that the problem you are experiencing is more related to the availability of the required fonts. If you place them in your environment and use the CellsHelper.setFontDir statement to point the API to these fonts, the results would be correct.

We still await for your response on our previous question about the usage of CellsHelper.setFontDir method in your application.

Working just fine.Thanks for the great support.



Itamar

Hi Itamar,


It’s good to know that you are up & running again. Please feel free to write back in case you need our further assistance with Aspose APIs.