1

I'm converting doc/docx files to html with JODConverter library(4.2.2) and LibreOffice (6.2). What I need is to save images as embedded in html file, but by default it saving in separate files.

In order to do that with LibreOffice command line interface i'm using:

soffice --convert-to html:HTML:EmbedImages example.docx

I'm wondering if there any way to pass option EmbedImages through JODConverter library?

My java code:

LocalConverter
    .make()
    .convert(new FileInputStream(docFile))
    .as(DefaultDocumentFormatRegistry.getFormatByMediaType(file.getMediaType().getName()))
    .to(htmlTempFile)
    .as(DefaultDocumentFormatRegistry.HTML)
    .execute();
hujakhujak
  • 28
  • 1
  • 5
  • Turning an HTML with external images to embedded images is really simple, reading all bytes, 1 call, Base64 bytes-to-text, 1 call, data url in tag/css (mime type png/jpeg). – Joop Eggen Apr 12 '19 at 08:23

1 Answers1

0

This would work:

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();
sbraconnier
  • 465
  • 5
  • 11
  • Doing the same still not working for me. It is still creating separate images – Dhiren Solanki Mar 25 '20 at 06:02
  • @DhirenSolanki Can you provide more detail ?? Which version are you using ? Can you create a sample project and share it ? You can also open an issue on github with a sample project if you can easily reproduce the problem. – sbraconnier Mar 25 '20 at 18:30