admin 管理员组

文章数量: 887016

openoffice将docx,doc,ppt,pptx转换pdf格式

1:先到官网下载。下载地址:/

        windows版本的下载:

                ·                        

2:下载安装后,进入安装目录(比如:C:\Program Files (x86)\OpenOffice 4\program)然后cmd 执行命令 soffice -accept="socket,host=0.0.0.0,port=8100,tcpNoDelay=1;urp;" -nofirststartwizard 开启远程和本地调用。

3:java代码如下

package com.zhengqing.demo.ppttopng;
import java.io.File;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.ExternalOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeConnectionProtocol;
import org.artofsolving.jodconverter.office.OfficeManager;
public class PdfUtil {/*** ppt转pdf* @param importFile 输入文件* @param exportFile输出文件*/public static void pptToPdf(File importFile, File exportFile) {// 如果目标路径不存在, 则新建该路径if (!outputFile.getParentFile().exists()) {outputFile.getParentFile().mkdirs();}ExternalOfficeManagerConfiguration configuration =new ExternalOfficeManagerConfiguration();configuration.setConnectionProtocol(OfficeConnectionProtocol.SOCKET);configuration.setPortNumber(8100);OfficeManager officeManager= configuration.buildOfficeManager();OfficeDocumentConverter officeDocumentConverter=new OfficeDocumentConverter(officeManager);officeDocumentConverter.convert(importFile, exportFile);}public static void main(String[] args) {File importFile= new File("H:\\mpe264\\docpdf\\7.ppt");File exportFile= new File("H:\\mpe264\\docpdf\\777777.pdf");PdfUtil.pptToPdf(importFile, exportFile);System.out.println("完成");}
}

本文标签: openoffice将docx doc ppt pptx转换pdf格式