Wednesday, 12 August 2020 06:51

Java set the intents and spacing for paragraph on the presentation slide

Written by  support iceblue
Rate this item
(0 votes)

There are two kinds of special indents styles for the paragraph on the presentation slides, first line and hanging. This article will demonstrate how to set the indents and spacing for the paragraph on presentation slide in Java applications.

import com.spire.presentation.*;

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

        //get the shapes
        IAutoShape shape = (IAutoShape) presentation.getSlides().get(0).getShapes().get(0);

        //set the indent, margin and space for the first paragraph
        shape.getTextFrame().getParagraphs().get(0).setIndent(20);
        shape.getTextFrame().getParagraphs().get(0).setLeftMargin(10);
        shape.getTextFrame().getParagraphs().get(0).setSpaceAfter(10);

        //set the indent, margin and space for the third paragraph
        shape.getTextFrame().getParagraphs().get(2).setIndent(-100);
        shape.getTextFrame().getParagraphs().get(2).setLeftMargin(40);
        shape.getTextFrame().getParagraphs().get(2).setSpaceBefore(0);
        shape.getTextFrame().getParagraphs().get(2).setSpaceAfter(0);

        //save the document to file
        String output = "output/result.pptx";
        presentation.saveToFile(output, FileFormat.PPTX_2010);
    }
}

Effective screenshot after setting the indent style of paragraphs on presentation slide:

Java set the intents and spacing for paragraph on the presentation slide

Additional Info

  • tutorial_title: