Issue with True Type Font of Aspose.Cells and Aspose.Slides

Hi,

I’m building a server for converting excel,word and ptt to pdf type.
My server belongs to AWS and his operating system in Linux.
I want to set in my projects custom fonts which was downloaded by me before.

Aspose.Words -
Everything is fine, I’ve used -
FontSettings.getDefaultInstance().setFontsFolders(new String[] { “/usr/share/fonts/”,"/usr/share/wine/fonts/"}, true);
and it works.

Aspose.Cells -
I’ve used - FontConfigs.setFontFolders(new String[] { “/usr/share/fonts/”,"/usr/share/wine/fonts/"}, true);
but the font is not changed.

Aspose.Slides -
I’ve used - FontsLoader.loadExternalFonts(new String[] { “/usr/share/fonts/”,"/usr/share/wine/fonts/"});
before any Presentation object creation as mentioned in its documentation

Class for loading custom fonts defined by user. Should be used before creating any presentation objects.

but the font is not changed and is not displayed propery.

Can someone help me? Am I missing something? I haven’t found a solution in the forums.

@Shaharsa

You are facing this issue due to missing fonts. You need to install fonts that are used in your document on the machine where you are exporting document to PDF. Please read the following articles.
Using Custom Fonts without Installing them

Get a List of Fonts used in a Spreadsheet or Workbook
Configuring Fonts for Rendering Spreadsheets

Thanks for your fast reply.

The fonts were successfully installed on my linux server because currently it works for Aspose.Words.
on the same code and on the same machine, Aspose.Words works but Aspose.Cells and Aspose.Slides don’t work.

Do I need to set something else for Cells and Slides?
for Words, the code line I’ve mentioned is enough, but for Cells and Slides isn’t enough.

Thanks.

@Shaharsa

Could you please ZIP and attach your input and problematic output documents here for testing? We will investigate the issue and provide you more information on it.

Ok, tomorrow I’ll attach the zip, for now I’ll clarify my issue.

It’s important to mention that I’ve installed on my Linux server msttcorefonts which includes many standard fonts in ‘/usr/share/fonts’ and in ‘usr/share/wine/fonts’ paths.

Aspose.Words - It does work:

        Document doc = new Document(dataDir + fileId + "." + extension);
		dataDir = dataDir + fileId.split("\\.")[0] + ".pdf";
		FontSettings.getDefaultInstance().setFontsFolders(new String[] {"/usr/share/fonts/","/usr/share/wine/fonts/"}, true);
		doc.save(dataDir, options);
		com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir);
		pdfDocument.save(dataDir);

Aspose.Cells - It does NOT work:

        String dataDir = Utils.getDataDir();
        Workbook workbook = new Workbook(dataDir + fileId + "." + extension);
        dataDir = dataDir + fileId.split("\\.")[0] + ".pdf";
        FontConfigs.setFontFolders(new String[] { "/usr/share/fonts/","/usr/share/wine/fonts/"}, true);
        workbook.save(dataDir);

Aspose.Slides - It does NOT work:

       FontsLoader.loadExternalFonts(new String[] { "/usr/share/fonts/","/usr/share/wine/fonts/"});
       String dataDir = Utils.getDataDir();
       Presentation pres = new Presentation(dataDir + fileId + "." + extension);
       dataDir = dataDir + fileId.split("\\.")[0] + ".pdf";
       pres.save(dataDir, SaveFormat.Pdf);

By saying ‘it does NOT work’ I mean to the fact that the installed fonts from the specified folder aren’t respected, and the default/custom aspose fonts are displayed only.

Many thanks.

@Shaharsa

Please ZIP and attach your input and problematic output documents for testing.

@Shaharsa,

Please move the following line of code from your code segment at the top:
FontConfigs.setFontFolders(new String[] { "/usr/share/fonts/","/usr/share/wine/fonts/"}, true);

Please note, the fonts setting API should be processed first and should be used before using any other Aspose.Cells APIs. Also, currently, Aspose.Cells only supports .ttf and .ttc font files. The .otf font files are not supported yet.

Hi,
Thanks.

Currently, the setFontFolders code is before any any other Aspose.Cells APIs but still it doesn’t work.
Any other ideas?

I’ve also tried the following code for Aspose.Slides:

    String[] fontsList = new String[5];
	fontsList[0] = (dataDir + "/usr/share/wine/fonts/symbol.ttf");
	fontsList[1] = (dataDir + "/usr/share/fonts/msttcore/arialbi.ttf");
	fontsList[2] = (dataDir + "/usr/share/fonts/msttcore/calibri.ttf");
	fontsList[3] = (dataDir + "/usr/share/fonts/msttcore/ariali.ttf");
	fontsList[4] = ("/home/ec2-user/usr/share/wine/fonts/symbol.ttf");
	
	FontsLoader.loadExternalFonts(fontsList);

but again, nothing works.
My ideas are getting over, I have been trying everything up to now.

Aspose.Cells and Slides True Type Font Issue.zip (2.9 MB)

Zip is attached, I really hope you could help me solve this annoying issue.
Many thanks.

@Shaharsa

We have tested the scenario using the latest version of Aspose.Cells for Java 19.5 and Aspose.Slides for Java 19.4. We have not found the shared issue with output PDF files. Please check the attached output PDF files.

Aspose.Slides output.pdf (82.1 KB)
Aspose.Cells output.pdf (93.4 KB)

We have noticed that you are generating the PDF files using Aspose.PDF. You can export Excel and Presentation files to PDF without using Aspose.PDF. If you still face problem, please ZIP and attach the fonts used in your documents (.xlsx and .pptx) here for further testing. We will investigate the issue and provide you more information on it.