Default Font Does Not Work when Converting PPTX to PDF in C#

I have a single slide PPTX, when I save as PDF, I get a different Font used vs when I save as PPTX.
I have specified the default Font in the load options to be the font used in the PPTX. I have tried changing the default font to other completely different font families and none of them get picked up, regardless of what I set the default font to, the PDF always saves the same way.

The text in the PPTX is in Metropolis and in the PDF it is Metropolis Semi Bold

Sample PPTX and PDF produced are here : ILT-Slides.zip (87.5 KB)

This code demonstrates the example

		string WorkFolder = TestRootFolder + "\\ILT-Slides";
		string input = Path.Combine(WorkFolder, "preview.pptx");
		string output = Path.Combine(WorkFolder, "preview.pdf");
		string lic = Path.Combine(WorkFolder, "aspose.lic");

		License license = new License();
		license.SetLicense(lic);

		Aspose.Slides.LoadOptions loadOptions = new Aspose.Slides.LoadOptions(LoadFormat.Auto)
		{
			DefaultRegularFont = "Metropolis-Regular"
		};

		Presentation thePres =  new Presentation(input, loadOptions);
		thePres.Save(output, SaveFormat.Pdf);

@gkalte,
Thank you for contacting support.
It will take me a while to investigate this case. We will reply to you as soon as possible.

@gkalte,
Thank you for your patience. Unfortunately, I was unable to reproduce the problem you described. Please check your results using the latest version of Aspose.Slides for .NET if it is possible. If the issue persists, please share the following information:

  • OS version on which the code was run
  • target .NET platform

When you say you were unable to reproduce, what does that mean?
You were able to save a PDF, where the text of the one slide was all in Metropolis and not Metropolis Semi-Bold?
Can you upload the PDF you created ?

I am running on windows 10 build 18363
.NET version 4.6.1

@gkalte,

I tested your code example with the default font set to other fonts (Arial and Times New Roman, for example), it works fine. By this I meant “unable to reproduce”.

It looks like the Metropolis font has not been installed on your operating system. If you need to use it in the output PDF, you should install the font or load it as external instead of using DefaultRegularFont property.

FontsLoader.LoadExternalFonts(folders);

Documents: Custom Font
API Reference: FontsLoader Class

I have tried the same thing ( Arial and Times New Roman ), and I always get the same result, Metropolis Semi - Bold. The metropolis fonts are installed in the windows font directory. can you post the code change you made to get it use Arial and/or Times New Roman

Thanks

@gkalte,
I just changed the default font in your code like this:

LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto)
{
    DefaultRegularFont = "Times New Roman"
};

Presentation thePres = new Presentation("preview.pptx", loadOptions);
thePres.Save("preview_out.pdf", SaveFormat.Pdf);

With Aspose.Slides 22.1, this is my output PDF: preview_out.pdf (46.9 KB). Could you please confirm you are using the latest version of Aspose.Slides?

Now I’m assuming that the font substitution was done incorrectly on your side. Could you please share the Metropolis and Metropolis Semi-Bold fonts from your system?

When I do this it stills save Metropolis Semi-Bold

image.png (76.8 KB)

Can you upload the PDF that is getting created ?
Is there anyway to generate a log of the save process ?
Times New Roman is an installed Font

@gkalte,
Please read carefully my message above and provide the requested data.

I confirmed I am using Aspose Slides.NET 22.1
image.png (22.5 KB)

The attached Zip has the metropolis fonts we have installed.
MetropolisFonts.zip (126.0 KB)

I think it is something more fundamental than font substitution, I can’t get any Font Family to work

@gkalte,
Thank you for the additional data. We are continuing to investigate this case and will reply to you soon.

@gkalte,
I’ve understood and reproduced the problem with the Metropolis fonts you described. You don’t need to use the DefaultRegularFont property for this case. The wrong Metropolis font was also selected when converting PPTX to PDF on my side.

I added a ticket with ID SLIDESNET-43040 in our issue tracking system. We apologize for any inconvenience. Our development team will investigate this case. You will be notified when the issue is resolved.

You could use a warning callbacks to detect font substitutions as shown below:

PdfOptions pdfOptions = new PdfOptions
{
    WarningCallback = new WarningHandler()
};

Presentation presentation = new Presentation("preview.pptx");
presentation.Save("preview_out.pdf", SaveFormat.Pdf, pdfOptions);
class WarningHandler : IWarningCallback
{
    public ReturnAction Warning(IWarningInfo warning)
    {
        Console.WriteLine(warning.WarningType);
        Console.WriteLine(warning.Description);
        return ReturnAction.Continue;
    }
}

But at the moment, there are some problems with warning callbacks for PDF export. So I linked this forum thread to a corresponding task with ID SLIDESNET-41996 in our issue tracking system. You will also be notified when this issue is resolved. Our development team is already working on the issue.

You can try to detect a font substitution during the loading stage of the presentation like this:

LoadOptions loadOptions = new LoadOptions
{
    WarningCallback = new WarningHandler()
};

Presentation presentation = new Presentation("preview.pptx", loadOptions);
presentation.Save("preview_out.pdf", SaveFormat.Pdf);

Documents: Getting Warning Callbacks for Fonts Substitution
API Reference: LoadOptions Class | IWarningCallback Interface

The issues you have found earlier (filed as SLIDESNET-41996) have been fixed in Aspose.Slides for .NET 22.4 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.