标签:page red tco 格式 dft com ice jar class
在官网下载的
Spire.Presentation.jar 包
https://www.e-iceblue.com/downloads/java/Spire.Presentation-FE_2.6.1.zip
package zyntest02; import com.spire.pdf.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; public class TestPdfToImg { public static void main(String[] args) throws IOException { PdfDocument pdf = new PdfDocument("f:\\123.pdf"); BufferedImage image; for(int i = 0; i< pdf.getPages().getCount();i++){ image = pdf.saveAsImage(i); File file = new File( String.format("f:\\ToImage-img-%d.png", i)); ImageIO.write(image, "PNG", file); } pdf.close(); } }
package zyntest02;
import com.spire.presentation.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public class PPTtoPNG {
public static void main(String[] args) throws Exception{
//创建Presentation对象
Presentation ppt = new Presentation();
//加载示例文档
ppt.loadFromFile("sample.pptx");
//遍历幻灯片
for (int i = 0; i < ppt.getSlides().getCount(); i++) {
//将幻灯片保存为BufferedImage对象
BufferedImage image = ppt.getSlides().get(i).saveAsImage();
//将BufferedImage保存为PNG格式文件
String fileName = String.format("ToImage.png", i);
ImageIO.write(image, "PNG",new File(fileName));
}
ppt.dispose();
}
}
ppt和pdf转图片(Spire.Presentation)
标签:page red tco 格式 dft com ice jar class
原文地址:https://www.cnblogs.com/zzsuje/p/12200484.html