这期内容当中小编将会给大家带来有关如何建立openoffice中docker镜像的dockerfile,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
FROM centos:7.7.1908 RUN yum -y install wget && \ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup && \ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && \ yum clean all && \ yum makecache ADD ./jdk-8u212-linux-x64.tar.gz /usr/local/ ENV JAVA_HOME /usr/local/jdk1.8.0_212 ENV JRE_HOME /usr/local/jdk1.8.0_212/jre ENV PATH $JAVA_HOME/bin:$JRE_HOME/bin:$PATH ADD ./Apache_OpenOffice_4.1.10_Linux_x86-64_install-rpm_zh-CN.tar.gz /tmp/Apache_OpenOffice_4.1.10_Linux_x86-64_install-rpm_zh-CN RUN cd /tmp && \ yum install -y /tmp/Apache_OpenOffice_4.1.10_Linux_x86-64_install-rpm_zh-CN/zh-CN/RPMS/*.rpm && \ yum install -y /tmp/Apache_OpenOffice_4.1.10_Linux_x86-64_install-rpm_zh-CN/zh-CN/RPMS/desktop-integration/openoffice4.1.10-redhat-menus-4.1.10-9807.noarch.rpm RUN yum install -y libXext.x86_64 && \ yum install -y gcc && \ yum install -y gcc-c++ && \ yum install -y freetype-devel && \ yum install -y glib2-devel && \ yum install -y cairo-devel ADD ./fonts /usr/share/fonts RUN cd /usr/share/fonts/ && \ chmod -R 755 /usr/share/fonts && \ yum install -y mkfontscale && \ yum install -y fontconfig && \ mkfontscale && \ mkfontdir && \ fc-cache -fv RUN yum groupinstall -y "X Window System" RUN yum -y install net-tools #暴露接口 EXPOSE 8100 #启动服务,占用8100端口 CMD /opt/openoffice4/program/soffice -headless -accept="socket,host=0.0.0.0,port=8100;urp;" -nofirststartwizard
java连接openoffice进行文件格式转换示例:
maven依赖
<dependency> <groupId>com.artofsolving</groupId> <artifactId>jodconverter</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>org.openoffice</groupId> <artifactId>jurt</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.openoffice</groupId> <artifactId>ridl</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.openoffice</groupId> <artifactId>juh</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.openoffice</groupId> <artifactId>unoil</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> <version>1.4.3</version> </dependency>
java代码实现
package openofficetest; import com.artofsolving.jodconverter.DocumentConverter; import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter; import com.sun.star.frame.XComponentLoader; import java.io.File; import java.net.ConnectException; /** * @author pxu * @create 2021-05-19 15:25 */ public class Main { public static void main(String[] args) { File srcFile = new File("E:\\tmp\\access_2013_05_30.csv"); File outFile = new File("E:\\tmp\\access_2013_05_30.xls"); convert(srcFile,outFile); } public static void convert(File sourceFile, File targetFile) { OpenOfficeConnection connection = null; try { connection = new SocketOpenOfficeConnection("172.25.2.168",8100); connection.connect(); DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection); converter.convert(sourceFile,targetFile); } catch (ConnectException e) { e.printStackTrace(); }finally { if(connection!=null) connection.disconnect(); } } }
上述就是小编为大家分享的如何建立openoffice中docker镜像的dockerfile了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。