Excel to PDF Header Font issue

Hello together

I have an Issue when converting an Excel file to PDF.
In the Header and Footer, some Font-Styles are missing in the resulting PDF.

In the Cells itself, the style is fine, but in the Header i’m missing Bold and Italic.

My Code:
using (var tmpWordDocumentStream = File.OpenRead(@“C:\Temp\TextExcel1.xlsx”))
{
var tmpDocument = new Aspose.Cells.Workbook(tmpWordDocumentStream);
tmpDocument.Save(@“C:\Temp\ExcelResult.pdf”, Aspose.Cells.SaveFormat.Pdf);
}

The file to repdoruce the issue:
TextExcel1.zip (6.6 KB)

@newwin-sws,

Thanks for the template file.

If you could open your file into MS Excel manually and check the print preview, you will notice that there is no data/text with bold and italic style in the header, so the output PDF by Aspose.Cells APIs would also keep the contents same as per the original Excel file, see the screenshot for your reference:

I have checked it with my Excel 2016 and got the following output:
Excel 2016 Printscreen.jpeg (55.9 KB)

@newwin-sws,

Thank you for providing the sample image, however we have also tested this sample file “TextExcel1.xlsx” in Excel 2007, Excel 2013 for Windows and Excel 2016 for Windows (Ver 16.0.9126.2259-32 bit ) and MacOS (Ver 16.16.1 (180814) both. I am afraid that we could not observe bold and italic characters in header as shown in the attached image.

Excel2016.png (28.9 KB)

Please confirm that have you sent us the correct file or not? Also check this file on some other systems too for verification. When we take the print preview, again there is no italic or bold words in the header. Once we get a file which has no issue in Excel but has issue while converted with the latest version of Aspose.Cells for .NET, we will provide our feedback.

Thank you for looking into this.
I have checked the File with Excel 2013 15.0.5059.1000 32Bit and Excel 2016 16.0.10325.20082 32Bit, both Result in the shown image above.
We have successfully tested it on three different Workstations.

I also tested how the file looks if I save it in Excel as pdf, then bold and Italiv are set Correct in the header.

I have created a new File, same Styles, different Font(arial):
TextExcel3, tested on two different workstations:
TextExcel3.zip (6.6 KB)

If this too fails, can you try to set the ‘Bold Text’ to Bold and then go into preview in Excel. Then it should be shown as Bold. Maybe you can reproduce the Issue that way.
Should it work with that File, yould you provide it to us?

Is it possible that this Issue is related to the language of the Computer or in Excel?

Thank you for your Help so far.

EDIT: I may have found the Issue: Language.
In German (my native Language), the Header looks like this, when i open it in Open XML SDK:
&L&"Arial,Standard"Simple Text&"Arial,Kursiv"Italic Text&C&"Arial,Fett"Bold Text&“Arial,Standard”&UUnderline Text

The two words (Kursiv, Fett) mean (Italic, Bold) in English. This would also explain why the Excel is broken on your PC’s.

Can you reproduce/fix this in Aspose?

@newwin-sws,

It seems that you are correct that issue is due to these German keywords. These German words should not be used while scripting the header and footer in Excel file. You may use English scripting commands only as mentioned here:

It shows that you should use “Bold” to make the text bold and “Italic” to make it italic in the header. I have tried this scenario by changing the Locale to Germany on Windows and open this file in Excel (I am using English version), it still does not show bold and Italic text in the header.

Please share which language is set in your Excel? Are you using MS Excel German version?

@newwin-sws,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46313 - Issues in output PDF when using German keywords in scripting headers and footers

I’m using MS Excel in German (Swiss).
Those Keywords get set in German when I create the Header from withing Excel.
After changing (Kursiv, Fett) to (Italic, Bold) manualy, excel still works.

I have tried setting Windows and Excel to Italian(Italia). I had to Install an additional language Pack to do so.
This results in the following Header String, created via MS Excel:
&LSimple Text&"-,Corsivo"Italic Text&C&"-,Grassetto"Bold Text

Excel also only recognizes ‘english’ and the ‘local language’ for the texts in the header (italic and bold styles).
The text seems to be the same as in the Infotext behind the two responsive icons.
Can you please fix this for every language.

Thank you for logging this Issue.

@newwin-sws,

We have recorded your feedback under the same issue. Once, we will have some news for you, we will update you in this topic.

@newwin-sws,

Please note, we won’t be able to fix this issue for every language. There are too many languages in the world you know. Actually, we can only support limited languages. We will add support for German language for sure. Also, Microsoft Excel cannot support every language without the corresponding language Microsoft Excel version installed. e.g. In our English Excel version, the German language header/footer font style is not supported.

Once we figure your issue for German language, we will share the Download link for the fix.

Thank you for your support.

I’ve also seen that Excel is unable to recognize an Italian Header after setting the main Language is set back to German.
I do belive that they only support the current language and english in the header.

Sad to know that there is no easy way to fix this.

@newwin-sws,

We will support German language at first. Do you also need Italian language support, we can check it later on.

We are currently good with German. Our Clients with other languages haven’t reached this issue so far.

@newwin-sws,

Alright, thanks for the update.

@newwin-sws,

Please try our latest version/fix: Aspose.Cells for .NET v18.8.3:

We have added support for German language font style keywords: “Standard”, “Fett”, “Kursiv”.

Also we have added new API:

GlobalizationSettings.GetStandardHeaderFooterFontStyleName(string localfontStyleName), in case there are other language font style keywords, you can override this API with your code (For example, using some translation engines), and here is a code example for Italian language font style keywords:

MyGlobalSettings myGlobalSettings = new MyGlobalSettings();
Workbook wb = new Workbook(srcFile);
wb.Settings.GlobalizationSettings = myGlobalSettings;
wb.Save(destFile.pdf);

MyGlobalSettings class:

public class MyGlobalSettings : GlobalizationSettings
{
    public override string GetStandardHeaderFooterFontStyleName(string localfontStyleName)
    {
        Console.WriteLine("Locale font style name: " + localfontStyleName);
        string standardName;
        switch (localfontStyleName)
        {
            case "Corsivo":
                standardName = "Italic";
                break;
            case "Grassetto":
                standardName = "Bold";
                break;
            default:
                standardName = localfontStyleName;
                break;
        }

        return standardName;
    }
} 

Hope, this helps. Let us know your feedback.

1 Like

Thank you very much
We have tried the fix and it works for our languages.

The GlobalizationSettings.GetStandardHeaderFooterFontStyleName is what we needed.
There is no additional need for a hard implementation of the German words for us.

Should anyone find this topic later, here is our switch for German/Italian/French:

public class MyGlobalSettings : GlobalizationSettings
{
    public override string GetStandardHeaderFooterFontStyleName(string localfontStyleName)
    {
        string standardName;
        switch (localfontStyleName)
        {
            case "Kursiv":
            case "Corsivo":
            case "Italique":
                standardName = "Italic";
                break;
            case "Fett":
            case "Grassetto":
            case "Gras":
                standardName = "Bold";
                break;
            case "Standard":
            case "Normale":
            case "Normal":
                standardName = "Default";
                break;
            default:
                standardName = localfontStyleName;
                break;
        }
        return standardName;
    }
}

@newwin-sws,

Good to know that your issue is sorted out by the new fix/version with given code segment. And, thanks for sharing the code segment for Italian/French switch cases, this will help others.

The issues you have found earlier (filed as CELLSNET-46313) have been fixed in Aspose.Cells for .NET v18.9. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi