本文概述
- Apache POI页面大小示例
- Apache POI设置页面大小示例
检索到的页面大小返回以点表示的坐标。让我们来看一个例子。
Apache POI页面大小示例
package poiexample;
import java.io.FileInputStream;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
public class SlideSizeExample {
public static void main(String[] args) {
try(XMLSlideShow ppt = new XMLSlideShow(new FileInputStream("srcmini.pptx"))){
java.awt.Dimension pgsize = ppt.getPageSize();
int width = pgsize.width;
//slide width in points
int height = pgsize.height;
//slide height in points
System.out.println("width: "+width);
System.out.println("height: "+ height);
}catch(Exception e) {
System.out.println(e);
}
}
}
【apache poi powerpoint页面大小】输出:
width: 720
height: 540
让我们来看一个设置页面大小的示例。
Apache POI设置页面大小示例
package poiexample;
import java.io.FileInputStream;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
public class SlideSizeExample {
public static void main(String[] args) {
try(XMLSlideShow ppt = new XMLSlideShow(new FileInputStream("srcmini.pptx"))){
java.awt.Dimension pgsize = ppt.getPageSize();
int width= pgsize.width;
//slide width in points
int height = pgsize.height;
//slide height in points
System.out.println("width: "+width);
System.out.println("height: "+ height);
ppt.setPageSize(new java.awt.Dimension(1024, 768));
java.awt.Dimension newpgsize = ppt.getPageSize();
System.out.println("\nSlide size after setting new size.");
System.out.println("width: "+newpgsize.width);
System.out.println("height: "+ newpgsize.height);
}catch(Exception e) {
System.out.println(e);
}
}
}
输出:
width: 720
height: 540
设置新尺寸后的幻灯片尺寸。
width: 1024
height: 768
推荐阅读
- apache poi powerpoint图像
- apache poi powerpoint幻灯片
- apache poi word文档段落
- apache poi超链接
- apache poi word表格
- apache poi word风格
- apache poi word对齐
- apache poi word提取文本
- apache poi word提取段落