我正在使用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();