Image running the OpenOffice 4 soffice daemon service(包括解决中文乱码问题)
50K+
Image running the OpenOffice 4 soffice daemon service, and solve the problem of Chinese code scrambling.(包括中文乱码问题)
This image was created by the https://github.com/xiaojun207/openoffice4-daemon
docker build --pull -t xiaojun207/openoffice4-daemon --build-arg OO_VERSION=4.1.7 .
docker run -d -u 123456 --name soffice -p 8100:8100 -v /data/:/data/ xiaojun207/openoffice4-daemon:latest
When you run this image the container will start the Openoffice daemon in headless mode listening on TCP port 8100 by default. To change this port pass the env var SOFFICE_DAEMON_PORT
If you use java, you can use jodconverter connect the container, like this:
import java.io.File;
import java.io.FileNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeManager;
...
public static void main(String[] args){
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
configuration.setOfficeHome("/opt/openoffice4");
configuration.setPortNumbers(8100);
configuration.setTaskExecutionTimeout(1000 * 60 * 5L);// 设置任务执行超时为5分钟
configuration.setTaskQueueTimeout(1000 * 60 * 60 * 24L);// 设置任务队列超时为24小时
OfficeManager officeManager = configuration.buildOfficeManager();
String inputFile = "/data/a.docx";
String pdfFile = "/data/a.pdf"; // 注意输出目录的docker写入权限,否则可能会失败
System.out.println("进行文档转换转换:" + inputFile + " --> " + pdfFile + ",isRunning:" + officeManager.isRunning());
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
converter.convert(new File(inputFile), new File(pdfFile));
}
docker exec -it soffice test
unoconvThe unoconv utility is available in this image! You can test a PDF conversion as follow:
.odt or .doc files into a dir (eg: ~/pdfs) in your host.docker run \
-v ~/pdfs:/pdfs:rw \
xiaojun207/openoffice4-daemon \
unoconv --connection 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1;urp;StarOffice.ComponentContext' \
-f pdf /pdfs/somefile.doc
.pdf inside the dir mounted as VolumeImageStreamoc import-image openoffice4-daemon --from=docker.io/xiaojun207/openoffice4-daemon --confirm --scheduled
DeploymentConfig to include the soffice container inside your App POD...
spec:
containers:
- image: >-
docker.io/xiaojun207/openoffice4-daemon@sha256:<image tag sha256>
imagePullPolicy: Always
name: soffice
ports:
- containerPort: 8100
protocol: TCP
...
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- soffice
from:
kind: ImageStreamTag
name: 'openoffice4-daemon:latest'
namespace: demo-tomcat6
lastTriggeredImage: >-
docker.io/xiaojun207/openoffice4-daemon@sha256:<image tag sha256>
type: ImageChange
...
Content type
Image
Digest
Size
445.7 MB
Last updated
over 6 years ago
docker pull xiaojun207/openoffice4-daemon