java - JODConverter & LibreOffice:将 doc 转换为带有嵌入图像的 html
问题描述
我正在使用 JODConverter 库(4.2.2)和 LibreOffice(6.2)将 doc/docx 文件转换为 html。我需要的是将图像保存为嵌入在 html 文件中,但默认情况下它保存在单独的文件中。
为了使用 LibreOffice 命令行界面来做到这一点,我正在使用:
soffice --convert-to html:HTML:EmbedImages example.docx
我想知道是否有任何方法可以通过 JODConverter 库传递选项EmbedImages?
我的java代码:
LocalConverter
.make()
.convert(new FileInputStream(docFile))
.as(DefaultDocumentFormatRegistry.getFormatByMediaType(file.getMediaType().getName()))
.to(htmlTempFile)
.as(DefaultDocumentFormatRegistry.HTML)
.execute();
解决方案
这会起作用:
final DocumentFormat format =
DocumentFormat.builder()
.from(DefaultDocumentFormatRegistry.HTML)
.storeProperty(DocumentFamily.TEXT, "FilterOptions", "EmbedImages")
.build();
LocalConverter
.make()
.convert(new FileInputStream(docFile))
.as(DefaultDocumentFormatRegistry.getFormatByMediaType(file.getMediaType().getName()))
.to(htmlTempFile)
.as(format)
.execute();
推荐阅读
- c# - 有没有办法以编程方式检测加密字符串中的 AES 加密级别?(128 对 192 对 256)
- javascript - 将脚本插入 div / 类
- reactjs - TypeError: (0 , _ApiCalls.default) 不是一个测试 axios 调用的函数
- regex - 在多个字符类上列出运算符而不使用匹配组
- node.js - ExpressJS:req.body 值以字符串“[object Object]”的形式出现
- swift - Swift 协议多个匹配函数命名错误
- java - 如何在Spring AOP中获取代理类的方法参数名称
- eclipse - Eclipse 在保存操作上非常慢。有什么办法可以改善这一点?
- python - pyramid.arima Anaconda 3 安装错误
- php - session_start() 防止在 Wordpress 编辑器中保存