Embed images when converting from HTML using libreoffice

I use headless libreoffice to convert HTML to various formats. For this question, we will use docx for simplicity.

I use a command like this:

libreoffice --headless --convert-to docx:"MS Word 2007 XML" --writer document.html 

This works fine for the most part.

HTML contains a couple of absolute image links.

 <img src="http://myserver.com/image1.jpg" /> 

When the document is converted to document.docx, the images are still linked, not embedded in the document. This causes problems when you are offline and in preview, etc.

Is there a way I can tell libreoffice to load and embed images directly into a document instead of just storing them as related images?

+5
source share
2 answers

LibreOffice currently (with respect to 6.3, but this is a situation, since this is a /5.2 change ) does not embed images by default:

 libreoffice --convert-to html test.odt 

You can connect images as follows:

 libreoffice --convert-to html:'HTML (StarWriter):EmbedImages' test.odt 
0
source

To convert to odt, this is pretty easy after installing pandoc.

After the relatively tough part: from odt (or even html) you can script (Open | Libre) Office through, for example. unoconv

Or you can:

abiword --to = doc filename .odt Also see this topic and this blog entry. To convert to odt, this is pretty easy after installing pandoc.

After the relatively tough part: from odt (or even html) you can script (Open | Libre) Office through, for example. unoconv

Or you can:

abiword --to = doc filename .odt Also see this topic and this blog entry.

-2
source

All Articles