Font Replacement - PowerPoint JavaScript API
Contents
[
Hide
]
If you change your mind about using a font, you can replace that font with another font. All instances of the old font will be replaced by the new font.
Aspose.Slides allows you to replace a font this way:
- Load the relevant presentation.
- Load the font that will be replaced.
- Load the new font.
- Replace the font.
- Write the modified presentation as a PPTX file.
This JavaScript code demonstrates font replacement:
// Loads a presentation
var pres = new aspose.slides.Presentation("Fonts.pptx");
try {
// Loads the source font that will be replaced
var sourceFont = new aspose.slides.FontData("Arial");
// Loads the new font
var destFont = new aspose.slides.FontData("Times New Roman");
// Replaces the fonts
pres.getFontsManager().replaceFont(sourceFont, destFont);
// Saves the presentation
pres.save("UpdatedFont_out.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}