该文将详细介绍如何使用spire.presentation for java设置幻灯片段落的缩进样式与间距。
import com.spire.presentation.*;
public class indentstyle {
public static void main(string[] args) throws exception{
//加载示例文档
presentation presentation = new presentation();
presentation.loadfromfile("sample.pptx");
//获取幻灯片图形
iautoshape shape = (iautoshape) presentation.getslides().get(0).getshapes().get(0);
//设置第一个段落首行缩进和间距
shape.gettextframe().getparagraphs().get(0).setindent(20);
shape.gettextframe().getparagraphs().get(0).setleftmargin(10);
shape.gettextframe().getparagraphs().get(0).setspaceafter(10);
//设置第三个段落悬挂缩进和间距
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);
//保存文档
string output = "output/indent.pptx";
presentation.savetofile(output, fileformat.pptx_2010);
}
}
效果图: