We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Change the Font Size in a PowerPoint Presentation?

We can replace the fonts like this - https://docs.aspose.com/slides/python-net/font-replacement/ - but can we change the font size in a similar way?

Could you please describe the issue in more detail? It would be great if you could share sample presentations (initial and expected).

As far as I know, there is no way to change the font size for all text in a presentation at once. You should list all presentation elements with text, and set a default font size for paragraphs and/or a font size for text portions of a paragraph. The following code example shows you how to do this:

import aspose.slides as slides

from aspose.slides import AutoShape
from aspose.slides.export import SaveFormat

with slides.Presentation("example.pptx") as presentation:
    # Get the first shape from the first slide, for example.
    shape = presentation.slides[0].shapes[0]

    if isinstance(shape, AutoShape):
        # Get the first paragraph, for example.
        paragraph = shape.text_frame.paragraphs[0]

        # Set the default font size for text portions of the paragraph.
        paragraph.paragraph_format.default_portion_format.font_height = 20

        # Set the size for the text portions of the paragraph.
        for portion in paragraph.portions:
            portion.portion_format.font_height = 20
    presentation.save("output.pptx", SaveFormat.PPTX)

I hope this helps. Please let us know if you need some simplest way.

API Reference: ParagraphFormat class | PortionFormat class

The reason I ask is because I want to change every instance of a certain font e.g. “Times New Roman” to a new font size regardless if it’s in a group, textbox, shape, table etc

Then you need to apply the approach for the shapes described here.

Thank you. I can’t work out when I’m searching for text with the same font I’m not picking up any fonts.

import aspose.slides as slides

with slides.Presentation('example.pptx') as presentation:
    for slide in presentation.slides:
        for shape in slide.shapes:
            if isinstance(shape, slides.AutoShape):
                for paragraph in shape.text_frame.paragraphs:
                    for portion in paragraph.portions:
                        font = portion.portion_format.latin_font

fontdetect.zip (27.8 KB)

You are getting None values instead of the actual fonts because the fonts have not been specifically set for the text elements. Instead, the fonts are inherited from parent objects (design theme, slide layout, slide master, etc.) in the presentation. If you want to get actual (final) properties of the text portion format, you should use the get_effective method like this:

font = portion.portion_format.get_effective().latin_font