Arial Narrow font missing in Excel to PDF rendering

Hi,
we are using aspose on a windows server to convert xlsx to pdf.
We didn’t install office on this server as we use Aspose.
When converting a xlsx using Arial Narrow, the result is not correctly formatted as the Arial Narrow font is not installed on the server because it’s installed by office.
How can we do ?

  • must we install office on the server … normally it should not be required as we use Aspose !?
  • are there a way to install such office fonts without installing office ?

Thanks in advance for your reply.

@tparassin,

Thanks for your query.

Well, for certain features, e.g Excel to PDF, Sheet to image, etc. Aspose.Cells requires the underlying fonts (used in the Workbook) to be installed before rendering workbook to PDF/images. it is necessary that the fonts used in the spreadsheet should be available in the operating system’s default font directory (or you may put the fonts in your custom directory but the folder should be specified by Aspose.Cells APIs at the start). In case the required fonts are not present then the Aspose.Cells APIs will try to substitute the required fonts with the ones available. We recommend you to kindly install/copy the underlying fonts (i.e., .ttf file(s)) only from other environment/location to your OS default fonts directory. Aspose.Cells does not require MS Office/Excel to be installed on the system. Also, on a safer side, you may set the fonts folder path using FontConfigs API, see the document for your reference:
https://docs.aspose.com/display/cellsnet/Configuring+Fonts+for+Rendering+Spreadsheets (.NET)
Configuring Fonts for Rendering Spreadsheets|Documentation (Java)

Thank you for your explanations.
“Aspose does not require MS Office to be installed” … but Aspose requires Office fonts, installed only with Office !?
When you say “We recommend you to kindly install/copy the underlying fonts (i.e., .ttf file(s)) only from other environment/location to your OS default fonts directory.”, the problem is that the office fonts are under license …
Do you know a non Office solution to get the Office fonts or compatible open source fonts ?
Thanks in advance.

@tparassin,

I am afraid, open type fonts (.otf files) are not supported. Without fonts, Aspose.Cells may not be able to correctly calculate text/characters’ glyph width/height when rendering spreadsheet to image/PDF, so the underlying fonts should be available/installed on the system for Excel to PDF conversion. On Windows os, all the main/baisic fonts are automatically installed when you install Windows.

you said : “On Windows os, all the main/baisic fonts are automatically installed when you install Windows”
but it’s not true for Arial Narrow for example …

So you confirm it’s mandatory to install office to be able to convert office documents using Arial Narrow to pdf with aspose ?

@tparassin,

For Arial Narrow font, I think you can browse online and download Arial Narrow font (.ttf file(s)). Install the font and use Aspose.Cells for rendering spreadsheet to PDF file format.

Sorry, but there is no Arial Narrow font available for commercial use on a server, or for a price higher than Aspose license !
I think that Aspose should provide office fonts (or at least office compatible fonts) to be able ti process office documents without office …

@tparassin,

We are very sorry but you must get font files by yourselves. As rendering features (e.g Excel to PDF and Sheet to Image) demand and use underlying font files, so those fonts should be available on the system before conversion. We know most fonts have copyrights. I am afraid, we cannot provide these fonts, so you have to get those font files. Aspose.Cells just uses font files provided by the users to render Excel files to PDF file format.

Hi,
we found a free font to replace Arial Narrow.
Coud you give me a sample in order to detect in Aspose that there is a missing font when converting to pdf and to tell to Aspose which font to use instead of Arial Narrow (but only when Arial Narrow is unavailable) ?
Thanks in advance.

@tparassin,

You can get the list of fonts used in the workbook, see the document for your reference:

You can specify the substitute font for rendering PDF/image files. This mechanism is helpful when a required font is not available on the machine where conversion has to take place, see the document for your reference:

Another way, can be by setting DefaultFont property of PdfSaveOptions and ImageOrPrintOptions to have priority, see the document with example for your complete reference:

See the code segment for your reference:
e.g
Sample code:

.........
//Rendering to PDF file format while setting the CheckWorkbookDefaultFont attribue to false.
//So, "Times New Roman" font would be used for any missing (not installed) font in the workbook.
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.DefaultFont = "My Font1";
saveOptions.CheckWorkbookDefaultFont = false;
workbook.Save(outputDir + "out1_pdf.pdf", saveOptions);

Hope, this helps a bit.

Thanks.
It helps me.
I can substitute a missing font with another one … but only with another one which is located in the windows system font directory.
Even if i use
FontConfigs.SetFontFolder(“d:\temp\Source_Sans_Pro”, false),
FontConfigs.SetFontSubstitutes(“Haettenschweiler”, new string[] { “PragatiNarrow” });
cannot substitute with PragatiNarrow which is located in d:\temp\Source_Sans_Pro …

how can i substitute with fonts located in a specific directory ?
Thanks in advance.

@tparassin,

Your code segment for specifying font folder and font substitution is right.

I have tested your scenario/ case a bit using a simple template file (attached). I have already installed “Haettenschweiler Regular” or “HATTEN” font on my Window8 pc. In the template file I used this font for a few cells data. Now I removed the font from “C:\Windows\Fonts” folder. I downloaded your custom font “pragati-narrow.zip” by browsing internet and extracted to my custom font folder (I extracted the two flavors, i.e., bold and regular of the font in the form of .ttf files). Now I use the following sample code and it works fine, it correctly replaces the missing font in the output PDF file format. I have also attached the output PDF file for your reference:
e.g
Sample code:

FontConfigs.SetFontFolder("E:\\test2\\mycustfontdir1", false);
            FontConfigs.SetFontSubstitutes("Haettenschweiler", new string[] { "Pragati Narrow" });

            Workbook workbook = new Workbook("e:\\test2\\Bk_custfont1.xlsx");
            workbook.Save("e:\\test2\\out1.pdf");

Please make sure that your custom folder “d:\temp\Source_Sans_Pro” does not have any restrictions and your application should have access to this folder.
files1.zip (27.5 KB)

yes, it works !
the problem came from the bad name used for the font : “PragatiNarrow” instead of “Pragati Narrow” !
Thanks for your help.

@tparassin,

Good to know that your issue is sorted out now. Feel free to write us back if you have further comments or questions, we will be happy to assist you soon.