Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Tue May 26, 2020 5:31 pm

Hi team,

Currently I'm using the library in java. I need to change the font size of all the content in a slide for the existing powerpoint. Can you please suggest me ?

Thanks,
Mohan.

tadiparthimohan
 
Posts: 3
Joined: Wed May 13, 2020 7:25 am

Wed May 27, 2020 6:30 am

Hi Mohan,

Thanks for your inquiry.
Please refer to the code below. If this doesn't meet your needs well, please provide us with your input file as well as your expected output. Then we will investigate further.
Code: Select all
    //Load a PPT document
    Presentation presentation = new Presentation();
    presentation.loadFromFile("test.pptx");

    for (Object o : presentation.getSlides().get(0).getShapes()) {
        if (o instanceof IAutoShape) {
            IAutoShape shape = (IAutoShape) o;
            for (Object paraObj : shape.getTextFrame().getParagraphs()) {
                ParagraphEx para = (ParagraphEx) paraObj;
                int max = para.getTextRanges().getCount();
                for (int i = 0; i < max; i++) {
                    para.getTextRanges().get(i).setFontHeight(14);
                }
            }
        }
        if (o instanceof ISmartArt) {
            ISmartArt shape = (ISmartArt) o;
            for (Object nodeObj : shape.getNodes()) {
                ISmartArtNode node = (ISmartArtNode) nodeObj;
                for (Object paraObj : node.getTextFrame().getParagraphs()) {
                    ParagraphEx para = (ParagraphEx) paraObj;
                    int max = para.getTextRanges().getCount();
                    for (int i = 0; i < max; i++) {
                        para.getTextRanges().get(i).setFontHeight(14);
                    }
                }
            }
        }
    }
    presentation.saveToFile("out.pptx", FileFormat.PPTX_2013);
}


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Jun 12, 2020 5:49 am

Hello,

Greetings from E-iceblue!
Does the code I provided work for you? Could you please give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Presentation