How Do I Change the Font of All Text to Arial without Having to Input an Original Font in Java?

Hello, I am using Aspose Slides in Java.

public Presentation changeFontFromTNRToArial(Presentation pres) {
    pres.getFontsManager().replaceFont(new FontData(OLD_FONT), new FontData(NEW_FONT));
    return pres;
}

Currently I am replacing font in my input pptx file with the above function. OLD_FONT and NEW_FONT are Strings set in the application. However, some input pptx presentations have several unpredictable fonts, all of which need to be converted to Arial. How do I do this without specifying the exact old font?

Thank you

@neelkri,
Thank you for posting the question.

For unpredictable fonts, you can set the default font using the LoadOptions class as follows:

LoadOptions loadOptions = new LoadOptions();
loadOptions.setDefaultRegularFont("Arial");

Presentation presentation = new Presentation("sample.pptx", loadOptions);

Then if you convert the presentation to PDF or images, the Arial font will be applied to all unknown fonts. I hope this will help you.
Default Fonts - PowerPoint Java API|Aspose.Slides Documentation

@andrey.potapov, thanks for your response. What if I am not converting the presentation to another format, but instead saving it to the cloud as a pptx?

@neelkri,
Unfortunately, PowerPoint documents do not have such an option. In this case, you can only use the approach described in your first post.

Thanks Andrey

@neelkri,
Thank you for using Aspose.Slides.