当前位置:首页 > 经验 >

pptx怎样转换成docx(pptx怎么转换成word)

来源:原点资讯(www.yd166.com)时间:2022-11-03 00:44:14作者:YD166手机阅读>>

1、安装LibreOffice

2、代码实现

package com.szoa.util.pdf; import java.io.File; import java.util.regex.Pattern; import org.jodconverter.OfficeDocumentConverter; import org.jodconverter.office.DefaultOfficeManagerBuilder; import org.jodconverter.office.OfficeException; import org.jodconverter.office.OfficeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PDFConvert { private static String officeHomeDir = null; private final static Logger logger = LoggerFactory.getLogger(PDFConvert.class); /** * *@name 文档转换为pdf工具类 *@description 相关说明 支持:xls,xlsx,ppt,pptx,txt,其中doc,docx转换与原文件有较大差异,libreOffice 默认安装路径 *Linux:/opt/libreoffice6.0 *Windows:C:/Program Files (x86)/LibreOffice *Mac:/Application/openOfficeSoft *@time 创建时间:2018年9月17日下午1:49:18 *@param sourceFile 需要转换的原文件 *@param tarPdfFile 转换后的目标pdf文件 *@return *@throws OfficeException *@author myflea@163.com *@history 修订历史(历次修订内容、修订人、修订时间等) */ public static String doDocToFdpLibre(String sourceFile, String tarPdfFile) throws OfficeException { File inputFile = new File(sourceFile); String libreOfficePath = getOfficeHome(); DefaultOfficeManagerBuilder builder = new DefaultOfficeManagerbuilder(); builder.setOfficeHome(new File(libreOfficePath)); // 端口号 builder.setPortNumber(8100); builder.setTaskExecutionTimeout(1000 * 60 * 5L); // 设置任务执行超时为5分钟 builder.setTaskQueueTimeout(1000 * 60 * 60 * 24L); // 设置任务队列超时为24小时 OfficeManager officeManager = builder.build(); startService(officeManager); OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager); File outputFile = new File(tarPdfFile); converter.convert(inputFile, outputFile); stopService(officeManager); String pdfPath = outputFile.getPath(); return pdfPath; } private static String getOfficeHome() { if (null != officeHomeDir) { return officeHomeDir; } else { String osName = System.getProperty("os.name"); if (Pattern.matches("Windows.*", osName)) { officeHomeDir = "C:/Program Files (x86)/LibreOffice"; return officeHomeDir; } else if (Pattern.matches("Linux.*", osName)) { officeHomeDir = "/opt/libreoffice6.0"; return officeHomeDir; } else if (Pattern.matches("Mac.*", osName)) { officeHomeDir = "/Application/openOfficeSoft"; return officeHomeDir; } return null; } } private static void stopService(OfficeManager officeManager) throws OfficeException { if (null != officeManager) { officeManager.stop(); } logger.info("关闭office转换成功!"); } private static void startService(OfficeManager officeManager) { try { // 准备启动服务 officeManager.start(); // 启动服务 logger.info("office转换服务启动成功"); } catch (Exception ce) { logger.error("office转换服务启动失败!详细信息:{}", ce); } } /** * *@name 设置libreOffice安装目录 *@description 相关说明:如果libreOffice安装目录为默认目录,则不需要设置,否则需要设置 *@time 创建时间:2018年9月17日下午1:52:36 *@param officeHome *@author 作者 *@history 修订历史(历次修订内容、修订人、修订时间等) */ public static void setOfficeHome(String officeHome) { officeHomeDir = officeHome; } }

3、pom.xml 依赖

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.szoa</groupId> <artifactId>szoa-pdf-util</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>soze-pdf-util</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceencoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.8.0-alpha2</version> </dependency> <dependency> <groupId>org.jodconverter</groupId> <artifactId>jodconverter-core</artifactId> <version>4.0.0-RELEASE</version> </dependency> </dependencies> <build> <finalName>szoa-pdf-util-${project.version}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.5.5</version> <configuration> <archive> <manifest> <mainClass>com.szoa.util.pdfmain.PdfDomain</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>

4、安装libreOffice

  1. 下载 版本6.0.6windows版本

安装流程:

pptx怎样转换成docx,pptx怎么转换成word(1)

pptx怎样转换成docx,pptx怎么转换成word(2)

pptx怎样转换成docx,pptx怎么转换成word(3)

pptx怎样转换成docx,pptx怎么转换成word(4)

  1. 下载linux版本

rpm安装方式安装

tar -zxvf LibreOffice_6.0.6_Linux_x86-64_rpm.tar.gz

cd LibreOffice_6.0.6

cd LibreOffice_6.0.6.2_Linux_x86-64_rpm/

cd RPMS/

rpm -ivh *.rpm

[root@bogon RPMS]# rpm -ivh *.rpm

Preparing... ########################################### [100%]

1:libreoffice6.0-ure ########################################### [ 2%]

2:libobasis6.0-core ########################################### [ 5%]

3:libobasis6.0-base ########################################### [ 7%]

4:libobasis6.0-impress ########################################### [ 10%]

5:libobasis6.0-writer ########################################### [ 12%]

6:libobasis6.0-calc ########################################### [ 15%]

7:libobasis6.0-draw ########################################### [ 17%]

8:libobasis6.0-en-US ########################################### [ 20%]

9:libobasis6.0-images ########################################### [ 22%]

10:libreoffice6.0 ########################################### [ 24%]

11:libobasis6.0-math ########################################### [ 27%]

12:libobasis6.0-pyuno ########################################### [ 29%]

13:libobasis6.0-librelogo ########################################### [ 32%]

14:libreoffice6.0-math ########################################### [ 34%]

15:libreoffice6.0-base ########################################### [ 37%]

16:libreoffice6.0-calc ########################################### [ 39%]

17:libreoffice6.0-dict-en ########################################### [ 41%]

18:libreoffice6.0-dict-es ########################################### [ 44%]

19:libreoffice6.0-dict-fr ########################################### [ 46%]

20:libreoffice6.0-draw ########################################### [ 49%]

21:libreoffice6.0-en-US ########################################### [ 51%]

22:libreoffice6.0-impress ########################################### [ 54%]

23:libreoffice6.0-writer ########################################### [ 56%]

24:libobasis6.0-ogltrans ########################################### [ 59%]

25:libobasis6.0-postgresql########################################### [ 61%]

26:libobasis6.0-extension-########################################### [ 63%]

27:libobasis6.0-extension-########################################### [ 66%]

28:libobasis6.0-extension-########################################### [ 68%]

29:libobasis6.0-extension-########################################### [ 71%]

30:libobasis6.0-extension-########################################### [ 73%]

31:libobasis6.0-extension-########################################### [ 76%]

32:libobasis6.0-firebird ########################################### [ 78%]

33:libobasis6.0-gnome-inte########################################### [ 80%]

34:libobasis6.0-graphicfil########################################### [ 83%]

35:libobasis6.0-kde-integr########################################### [ 85%]

36:libobasis6.0-onlineupda########################################### [ 88%]

37:libobasis6.0-ooofonts ########################################### [ 90%]

38:libobasis6.0-ooolinguis########################################### [ 93%]

39:libobasis6.0-python-scr########################################### [ 95%]

40:libobasis6.0-xsltfilter########################################### [ 98%]

41:libreoffice6.0-freedesk########################################### [100%]

/usr/bin/update-desktop-database

/usr/bin/update-mime-database

mkdir: 无法创建目录"/usr/share/icons/hicolor/icon-theme.cache": 不是目录

mkdir: 无法创建目录"/usr/share/icons/hicolor/index.theme": 不是目录

/usr/bin/gtk-update-icon-cache

/usr/bin/gtk-update-icon-cache

/usr/bin/update-desktop-database

/usr/bin/update-desktop-database

默认安装目录:/opt/libreoffice6.0

栏目热文

如何在电脑上看pptx文件(电脑安装啥能打开pptx文件)

如何在电脑上看pptx文件(电脑安装啥能打开pptx文件)

别以为PPT文档会服服帖帖地从电脑上传送到移动端,这里面有不少学问可循。有时由于兼容性问题,就算我们顺利转存过去,想要兼...

2022-11-03 00:48:57查看全文 >>

pptx格式在电脑上怎么打开(怎样打开pptx格式文件)

pptx格式在电脑上怎么打开(怎样打开pptx格式文件)

你有没有遇到这样的场景,网上下载或者收到了一个WPS的专用文档,但是自己电脑上只有微软OFFICE,此时如何打开呢?必须...

2022-11-03 00:59:52查看全文 >>

pptx用什么软件才能打开(pptx手机能打开吗)

pptx用什么软件才能打开(pptx手机能打开吗)

.PPT格式(文件)是MS Office 2003 版本中的 Power Point生成的文档。PPT(幻灯片),就是P...

2022-11-03 00:44:54查看全文 >>

pptx文件怎么打开(pptx文件正常可以打开吗)

pptx文件怎么打开(pptx文件正常可以打开吗)

xlsx文件怎么打开呢?我想这个问题肯定困扰了一部分人。Excel 2003或之前的版本保存的表格默认格式一般是“xls...

2022-11-03 00:59:52查看全文 >>

pptx手机能打开吗(手机上的pptx怎么打开)

pptx手机能打开吗(手机上的pptx怎么打开)

在外出差的领导突然发微信:小李,麻烦帮我把PPT转下文档,我要发给客户,我在外面不方便。小李:好的。(小李内心:领导要转...

2022-11-03 00:37:41查看全文 >>

ppt怎么改成pptx(ppt怎么转换为pptx)

ppt怎么改成pptx(ppt怎么转换为pptx)

有一些在PPT中藏的很深的冷门技巧,这次一次性都给大家挖出来了!比如PPT的皮肤居然还有黑色和灰色,你是不是不知道?比如...

2022-11-03 00:29:17查看全文 >>

pptx怎么打开(怎么打开pptx文件)

pptx怎么打开(怎么打开pptx文件)

【自名师微课堂】:教师实用技巧之如何打开pptx文件,本系列课程主要就是为教师介绍一些实用的技巧,让教师在备课...

2022-11-03 00:32:48查看全文 >>

pptx格式用什么软件打开(怎样打开pptx格式文件)

pptx格式用什么软件打开(怎样打开pptx格式文件)

平常打开 Office 软件(Word、Excel、PowerPoint),大家有没有觉得有点慢呢?为了提升软件利用效率...

2022-11-03 00:31:47查看全文 >>

pptx什么格式打开(pptx文件正常可以打开吗)

pptx什么格式打开(pptx文件正常可以打开吗)

简介:大家知道,演示文稿有两种常见的格式:ppt和pptx。那这两种格式的区别是什么呢?又有什么联系?下面给大家总结一下...

2022-11-03 00:29:40查看全文 >>

pptx适合什么格式图(pptx格式怎么编写)

pptx适合什么格式图(pptx格式怎么编写)

PPT就是Power Point简称,记得这只是简称并不是缩写。Power Point这个软件是微软公司出品的Micro...

2022-11-03 01:07:39查看全文 >>

文档排行