JODConverter和LibreOffice:将doc转换为嵌入图像的html

问题描述 投票:1回答:1

我正在使用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();
java libreoffice jodconverter
1个回答
0
投票

这可行:

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();
© www.soinside.com 2019 - 2024. All rights reserved.