Java 拆分PPT幻灯片
1、方法1: 可通过e-iceblue官网下载。下载后,解压文件,将lib文件夹恩劣矿下的Spire.Presentation.jar文件导入java程序。
2、方法2:可通过maven仓霜仗库安装导入,配置路径胳诸及导入方法可参考链接里的步骤:https://www.e-iceblue.cn/licensing/install-spirepdf-for-java-from-maven-repository.html 。
3、测试文档如下,包含4页幻灯片内容:
1、import com.spire.presentation.*;
public class Split1 {
public static void main(String[] args)throws Exception {
//加载测试文档1
Presentation ppt1 = new Presentation();
ppt1.loadFromFile("test1.pptx");
//遍历文档1
for (int i = 0; i < ppt1.getSlides().getCount(); i++) {
//新建一个PPT文档,并移除默认生成的第一页幻灯片
Presentation newppt = new Presentation();
newppt.getSlides().removeAt(0);
//将每一页添加到新建的文档,并保存
newppt.getSlides().append(ppt1.getSlides().get(i));
newppt.saveToFile(String.format("单页拆分-%1$s.pptx", i), FileFormat.PPTX_2013);
}
}
}
2、拆分效果:
1、import com.spire.presentation.*;
public class Split2 {
public static void main(String[] args) throws Exception{
//加载文档1
Presentation ppt1 = new Presentation();
ppt1.loadFromFile("test1.pptx");
//新建文档1,移除默认生成的第一页幻灯片
Presentation newppt1 = new Presentation();
newppt1.getSlides().removeAt(0);
//将文档1中的第一、二页添加到新建的文档1,并保存
for (int i = 0; i < 2; i++)
{
newppt1.getSlides().append(ppt1.getSlides().get(i));
}
newppt1.saveToFile(String.format("拆分1.pptx"), FileFormat.PPTX_2013);
//新建文档2,移除默认生成的第一页幻灯片
Presentation newppt2 = new Presentation();
newppt2.getSlides().removeAt(0);//将文档2中的第三、四页添加到新建的文档2,并保存
for(int j = 2;j < 4;j++){
newppt2.getSlides().append(ppt1.getSlides().get(j));
}
newppt2.saveToFile(String.format("拆分2.pptx"), FileFormat.PPTX_2013);
}
}
2、拆分结果:
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:134
阅读量:113
阅读量:40
阅读量:170
阅读量:81