Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed images when converting from HTML with libreoffice

I'm using libreoffice in headless mode to convert HTML into various formats. For this question, we'll use docx for simplicity sake.

I use a command similar to this:

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

This works great for the most part.

The HTML includes a couple of absolute links to images.

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

When the document is converted to document.docx, the images are still being linked to, not embedded into the document. This causes problems when you're offline and in previews and such.

Is there a way that I can tell libreoffice to download and embed the images directly into the document instead of just keeping them as linked images?

like image 365
user1052474 Avatar asked Apr 30 '13 16:04

user1052474


1 Answers

LibreOffice currently (towards 6.3, but this is the situation since this change / 5.2) defaults to not embed images:

libreoffice --convert-to html test.odt

You can opt in to embed images like this:

libreoffice --convert-to html:'HTML (StarWriter):EmbedImages' test.odt
like image 167
Miklos Vajna Avatar answered Sep 23 '22 09:09

Miklos Vajna