在线浏览ppt(当然doc,xls都是可以得)的思路是
版本为3.4.1,高版本可能不支持
cd C:\Program Files (x86)\OpenOffice.org 3\program
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;
解压hyperic-sigar-1.6.4到任意E盘(随意)
进入jodconverter-core
目录
运行maven命令
mvn -Djava.library.path=E:/hyperic-sigar-1.6.4/sigar-bin/lib -DskipTests install
jodconverter-core-3.0-SNAPSHOT.jar
,<dependency>
<groupId>org.artofsolving.jodconverter</groupId>
<artifactId>jodconverter-core</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
代码,默认在Spring的环境下
@Service
public class PptConverter {
public void ppt2PDF(File inputFile, File outputFile) {
// 如果目标路径不存在, 则新建该路径
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
// convert
ExternalOfficeManagerConfiguration configuration =
new ExternalOfficeManagerConfiguration();
configuration.setConnectionProtocol(OfficeConnectionProtocol.SOCKET);
configuration.setPortNumber(8100);
OfficeManager officeManager= configuration
.buildOfficeManager();
OfficeDocumentConverter converter =
new OfficeDocumentConverter(officeManager);
converter.convert(inputFile, outputFile);
}
}
@Autowired
PptConverter pptConverter;
@RequestMapping("xx")
public String convertAndView() throws Exception{
File inputFile = new File("输入路径---请自行修改");
File outFile = new File("输出路径---请自行修改");
pptConverter.ppt2PDF(inputFile,outFile);
return "viewer";
}
xx
http://localhost:8080/xx/#../xx/test2.pdf
iframe
嵌入这个地址到别的页面原文:http://wiselyman.iteye.com/blog/2216667