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

Free Support Forum - aspose.com

Chinese fonts are missing for excel to pdf

When I save a excel to pdf on linux, all the chinese fonts are missing.

However, word and ppt works fine on the same machine

The source and destination docs are attached.

The code is as following:

Workbook workbook = new Workbook(sourcePath);

workbook.save(targetPath, com.aspose.cells.SaveFormat.PDF);

The font of the cell is 宋体

and the font is correctly installed as following:



Thanks for your posting and using Aspose.Cells.

Please copy your required fonts in some directory in your Linux machine and then set the font directory using CellsHelper.setFontDir method. Please place this line at the beginning of the code before converting it to PDF.

For example see the following code, here you have placed the fonts inside the winfont directory.



Workbook workbook = new Workbook(sourcePath);

workbook.save(targetPath, com.aspose.cells.SaveFormat.PDF);

Cool. It works fine.

But why word and powpoint can find the fonts automatically?

Can cell find the fonts automatically?

Hi Huangfu,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved by adding the CellsHelper.setFontDir() method.

To search the font path automatically, commonly we add the lib/fonts under
javahome as one of the font dirs. And for sun’s JDK of 1.5/1.6, we try to use
the FontManager to get some other font paths.

However this depends on special
JDK vendor and version and system settings. Sometimes those automatically
detected font paths take effect(required fonts can be found under them) and user
need not to write additional code for rendering. But if user know those font
paths used for their application, it is better to set them explicitly so that
your application can give correct result always.