Wednesday, 09 September 2020 07:18

Remove Text Box in PowerPoint in Java

Written by  support iceblue
Rate this item
(0 votes)

This article demonstrates how to remove text box in a PowerPoint document by using Spire.Presentation for Java.

Below is a screenshot of the original PowerPoint document:

Remove Text Box in PowerPoint in Java

import com.spire.presentation.*;

public class removeTextBox {
    public static void main(String[] args) throws Exception {
        //Load the sample document
        Presentation ppt = new Presentation();
        ppt.loadFromFile("sample.pptx");

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Traverse all the shapes in the slide and remove the textboxes
        for (int i = slide.getShapes().getCount() - 1; i >= 0; i--) {
            IAutoShape shape = (IAutoShape) slide.getShapes().get(i);
            if (shape.isTextBox()) {
                slide.getShapes().removeAt(i);
            }
        }

        //Save the document
        ppt.saveToFile("output/removeTextBox.pptx", FileFormat.PPTX_2013);
    }
}

Output

Remove Text Box in PowerPoint in Java

Additional Info

  • tutorial_title:
Last modified on Friday, 11 September 2020 06:00