Aspose.Cells - Font becomes bold during Excel to PDF conversion

Hi, I’m using Aspose Cells to convert an Excel spreadsheet file into a PDF file and the original font in the spreadsheet (Helvetica regular) becomes bold in the output PDF. I checked that the font is installed and is located in C:\Windows\Fonts. Here is the code I am using:

PdfSaveOptions options = new PdfSaveOptions();
options.OptimizationType = PdfOptimizationType.Standard;
_workbook.Save(outputPath, options);

When I save to PDF using Excel, the original font is retained. I’ve attached the Aspose PDF output, and the Excel PDF output for comparison. Is there any way to retain the font appearance with the Aspose conversion? I also have the input Excel file, but am unable to attach it here. Let me know if there is another way to send it over. Thank you. aspose_output.pdf (56.0 KB)
excel_output.pdf (33.7 KB)

@sdonapati,

We need your template Excel file to evaluate your issue. Please zip and attach your input Excel file, we will check it soon.

I’ve zipped and attached the input Excel file below.input.zip (27.0 KB)

@sdonapati,

Thanks for the template file.

Could you also provide fonts(.ttf) files (e.g., Helvetica) used in the workbook, so we could evaluate your issue precisely.

Yes, I zipped the font files and attached them below. Fonts.zip (690.4 KB)

@sdonapati,

Thanks for the font files.

I did install your provided font in “C:\Windows\Fonts” prior evaluating your scenario/case. Please notice, I am able to reproduce the issue as you mentioned by converting your template file to PDF file format. I found the font text becomes bold during Excel to PDF conversion. The font "Helvetica " regular becomes bold in the output PDF. I have logged a ticket with an id “CELLSNET-50771” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@Amjad_Sahi

Thanks for creating this ticket. Is there an approximate ETA for the fix or is there a workaround we can use in the meantime? This issue is critical for us at the moment.

@sdonapati,

Please spare us little time to evaluate your issue thoroughly. We will try to figure out your issue soon. If it requires more time, we will share an ETA on it.

Ok, thank you.

@sdonapati

The font file “HELVETICA-BOLD.TTF” is expected to be Bold style, but it is Regular style defined in ‘OS/2’ font table. Please check the dumped ‘OS/2’ font table:

Reference: OS/2 - OS/2 and Windows metrics table (OpenType 1.9) - Typography | Microsoft Learn

So, The font file “HELVETICA-BOLD.TTF” and “HELVETICA.TTF” are both Regular style, which makes Aspose.Cells use the wrong “HELVETICA-BOLD.TTF” font for Regular style.

If you uninstall “HELVETICA-BOLD.TTF” font, the result will be OK.

@Peyton.Xu

Thank you for the reply. I tested uninstalling “HELVETICA-BOLD.TTF” , but now I’m getting this error returned from the dll:

Could not find file ‘C:\Users\sdonapati\AppData\Local\Microsoft\Windows\Fonts\Helvetica-Bold.ttf’

@sdonapati

Aspose.Cells checks whether the font file is exist or not first. So the error should not be reported.
Could you please share us a project to reproduce the error?

However, if the font file was deleted, you can remove the item with value C:\Users\sdonapati\AppData\Local\Microsoft\Windows\Fonts\Helvetica-Bold.ttf in
Windows Registry Editor: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts

@Peyton.Xu
I’ve created a simple VS project to be called from the command line, but the compressed project size is greater than 50mb so it cannot be uploaded here. Is there any other way to send it over?

I checked that location in Windows Registry Editor, but there are no keys on my machine for that font (see screenshot below). Screenshot_83.png (7.1 KB)

Thank you.

You may upload the sample to some file sharing service (Google drive, dropbox, etc.) and share the Download link here, so we could download it seamlessly.

I’ve uploaded the compressed project files to Dropbox, here is the link: Dropbox - AsposeTest.zip - Simplify your life

Let me know if it works, the folder should only be missing the “Aspose.NET.Cells.lic” file which I removed so it is not publicly shared.

@sdonapati,

Thanks for the sample project.

We will evaluate it and get back to you soon.

@sdonapati

With your shared project, it works OK after uninstall HELVETICA-BOLD.TTF font.

Please check that:

  1. Where is the font HELVETICA.TTF installed from C:\Windows\Fonts?
    Windows Fonts
  2. The register key/value at Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
  3. The exception stack info.
  4. What is your System environment info?

Also, Please try to reintall the font HELVETICA-BOLD.TTF again, then uninstall it from C:\Windows\Fonts, then run your project again.

Windows Fonts

@Peyton.Xu

I retested by uninstalling all Helvetica fonts and then installing only Helvetica Regular, and this works now. However, this workaround won’t work for our application because the input Excel file may or may not contain Helvetica Bold and if it is not installed, it looks like Aspose will use a different font.

Is there possibly a workaround in the C# code that would correctly handle an input Excel file with both Helvetica and Helvetica Bold text? If not, do you know if the OS/2 table can be updated to the correct style for these fonts? Is the style that is set based on the font files or the OS version? Are there any other known common fonts that this issue occurs for? Lastly, can this potentially fixed by a future Aspose update? Thank you for your help with this.

@sdonapati

We will try to fix it.

@sdonapati,

This is to inform you that your issue (logged earlier as “CELLSNET-50771”) has been resolved now. The fix will be included in the next release (Aspose.Cells for .NET v22.5) which is scheduled in the second week of May 2022. You will also be notified when the next version is released.