Font Styles Are Not Applying when Exporting to PDF and Images

Hi Team, we are using upgraded aspose.slide library v21.02.0, where are not able generate tumbnail image properly and exporting it to ppt and pdf showing a blank slide, it working some times correct and sometime it is not,

if i use v20.10 library it working fine with loading custom fonts in tumbnails and exporting to pdf, but here only exporting to ppt is not loading correct font styles ,
Please help me to reslove this issue.

@MahadeviKumbar,
Thank you for the issue description. We need the next information to investigate your case:

  • A code example reproducing the problem
  • The presentation files
  • The external fonts (if used)
  • The expected and actual results (screenshots or description)

Hi Andrey, I have noticed if slides contains font -family of Hp simplified light ,Hp simplified bold etc are in slide then it is not working properly. Thumbnails is showing blank if it has text. if text has Hp Simplified then it applying.
I have used v20.10, with loading memory fonts externally then except thumbnail its working fine.

// LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
// loadOptions.DocumentLevelFontSources.FontFolders  = new string[] { “assets\fonts”, “global\fonts” };
// loadOptions.DocumentLevelFontSources.MemoryFonts = getMemoryFontsofTtf();

                presentation = new Presentation(slidePath);
                var slide = presentation.Slides[0];
                var image = GetImage(slide, height, width);

                if (image != null)
                {
                    using (var stream = new MemoryStream())
                    {
                        image.Save(stream, ImageFormat.Jpeg);
                        return stream.ToArray();
                    }
                }

Please help me out…

Hi Andrey ,

Please find below attachment for your reference.

(Attachment test slide.ppt is missing)

tumnail image in jpg.PNG.jpg (35.3 KB)

pdf image.PNG.jpg (89.5 KB)

@MahadeviKumbar,
I cannot check your code example containing an unknown GetImage method.
I made a presentation containing a text with “Hp Simplified” font. I made a slide thumbnail and found no problems.

You should share your own presentation file for investigating the issue. Also, please share a comprehensive code snippet and fonts that are used in the presentation.

Hi Andrey,

If slide contains font families like HP Simplified , HP Simplified Light, HP Simplified Bold, HP Simplified Bold Italic, HP Simplified Regular then it sometime works, and some time not working for exporting pdf, ppts and thumbnails also.
I’m loading all font families while exporting the slide. For the fonts you can get by downloading from internet.

Please find attached file fyi.

image002.jpg (169 Bytes)

New folder.zip (1.67 MB)

@MahadeviKumbar,
I used the next code example for your presentation files and found no problems you have mentioned:

using (var presentation = new Presentation(presentationFilePath))
{
    presentation.Slides[0].GetThumbnail(1, 1).Save("result.jpg", ImageFormat.Jpeg);
    presentation.Save("result.pdf", SaveFormat.Pdf);
    presentation.Save("result.ppt", SaveFormat.Ppt);
}

Could you please specify the OS version your code was running on?
Have the fonts been installed on the OS? Or are they in a folder?

@Andrey Potapov via Free Support Forum - aspose.com ,

I’m running on windows with intel core- i5 processor, Fonts are not installed on machine/client. We are having fonts in separate folder of our project and externally I’m loading all the hp font faces of HP font-family while exporting a slide into .pdf, .ppt and .jpg formats.

I want to clarify whether all-font faces are required to install on client/remote machine? Then it works?

Please let me know.

image002.jpg (169 Bytes)

@MahadeviKumbar,

Could you please share a code example loading these fonts that can be compiled and checked on our end?

You can try that way as well.

@Andrey Potapov via Free Support Forum - aspose.com,

FYI: I’m loading all the hp font faces of HP font-family while exporting a slide into .pdf, .ppt and .jpg formats. In my local its working fine but After the deployment code, it is not working properly when remote pc/client system those who not having these HP fonts.

image002.jpg (169 Bytes)

image004.jpg (163 Bytes)

@Andrey Potapov via Free Support Forum - aspose.com, Please find the code.

image002.jpg (169 Bytes)

image004.jpg (163 Bytes)

New Text Document.zip (1.11 KB)

@MahadeviKumbar,
Please try to use FontsLoader as below:

FontsLoader.LoadExternalFonts(fontFolders);

API Reference: FontsLoader Class

Also, when some fonts are missing from the operating system, you can use a default font as below:

LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
loadOptions.DefaultRegularFont = "your_default_font_name";

More details: Default Font
API Reference: LoadOptions.DefaultRegularFont Property

@Andrey Potapov I have tried with suggestion what are you shared in the comments. Still I’m facing same issue i.e. while downloading ppt. are not showing correct font format. Please can you suggest any other ways.

@Andrey_Potapov , While embedding fonts on slide thats works if slide does not having any links /other special formats,
How to handle links which does in the slide
image002.jpg (169 Bytes)

@MahadeviKumbar,
All of your uploaded image files (image002.jpg and image004.jpg) are empty white squares. What do you try to commit?

@Andrey_Potapov , I’m not adding this image (image002.jpg and image004.jpg), it is adding by default while replying via mail.

Did you find any solution for how to handle links on slide if we embedding fonts into slide with help of addEmbeddedFont()?

@MahadeviKumbar,

Is your client’s operating system also Windows?
Please check the accessibility of fonts in the client’s machine (try to read the “Hp Simplified” font file).
Could you please share a simple standalone project with the problem for investigation on our end?

Also, you can try to load external fonts as below:

FontsLoader.LoadExternalFont(File.ReadAllBytes("font.ttf"));
try
{
    using (Presentation presentation = new Presentation("pres.pptx"))
    {
        presentation.Save("out.pdf", SaveFormat.Pdf);
    }
}
finally
{
    FontsLoader.ClearCache();
}

We need more details for this issue.

I don’t know which operation system may they will use. But I’m running on Windows operating system still I’m unable to see expected fonts on ppt. I tried your solution that did not work for me.

While embedding font on slide works if its does not contains any links/special format.

image002.jpg (169 Bytes)

image004.jpg (163 Bytes)

@MahadeviKumbar,

Please share a presentation file with such links.

Also, please check messages about font substitutions as below:

LoadOptions loadOptions = new LoadOptions();
loadOptions.WarningCallback = new FontWarningHandler();

Presentation presentation = new Presentation(pptxPath, loadOptions);
presentation.Save(pdfPath, SaveFormat.Pdf);

More details: Getting Warning Callbacks for Fonts Substitution