Is there an easy way to convert HTML(with CSS styles and embedded images) to ODT, DOCX, DOC from the command line on linux server. I searched a lot but have not found a good option. There was a problem the same way to convert to PDF, decided by wkhtmltopdf. Perhaps there are ways to convert the resulting PDF documents to other formats?
-
If someone wants the other way round, you can use [this great github tool named Docx2Html](https://github.com/Elagoht/Docx2Html). – Cadoiz Sep 07 '22 at 12:09
5 Answers
To convert to odt
it's pretty easy after installing pandoc
.
After the relatively hard part: from odt
(or even html
) you can script (Open|Libre)Office via e.g. unoconv
Or you can like:
abiword --to=doc filename.odt
Also see this thread, and this blog post.
HTH

- 1
- 1

- 50,406
- 14
- 85
- 110
-
1Pandoc good thing - what i was looking for. But i have a problem with the tables - they are converted into regular sections - tables will be in each document and they are very important. – user1081056 Dec 05 '11 at 12:58
-
1For pdf im using *wkhtmltopdf*, for server required to use xvfb - but result is perfect. – user1081056 Jul 26 '12 at 12:02
-
1Just tried *pandoc*, it is bad. It does not work properly with image sizes, and from my searching it is a long standing problem. – Hi-Angel May 09 '15 at 23:00
-
1Okay, just tried abiword. It have a minus — didn't worked either: being started like a converter in terminal it is just crashing with `Aborted(core dumped)`. But it have a plus — it is a graphical app, and it is possible to launch it, next open an html, next «save as» odt. But it have a minus: it moves an image for unknown reason to a second page *(and I didn't tried yet add more images to the html)*. Omg… Okay, screw it, I hope my university won't be against html instead of an office document… – Hi-Angel May 09 '15 at 23:17
-
1As of September 2017, Pandoc still does not convert slightly more complex tables containing eg colspan https://github.com/jgm/pandoc/issues/1024 – askrynnikov Sep 28 '17 at 13:18
If you want to convert HTML into docx you may use a solution like PHPDocX. You need to get the PRO version though because the free one does not include the conversion functionality.

- 416
- 3
- 8
-
Well, I am one of the developers of PHPDocX so I know the tool and I comment on it when I feel that it can be useful to anyone...I hope that there is nothing wrong with that :-) – Eduardo Ramos Jan 26 '13 at 07:50
-
5Nothing wrong by itself, though one can question the sincerity of the answer if you post anonymously. What are you hiding? :) If you add "Disclosure: I am one of the developers of..." to such answers you make a much better impression. – johndodo Sep 12 '13 at 07:50
-
@EduardoRamos how does phpdocx handle html > docx? Do I need to convert my html file with eternal resources to be entirely inline (including base64 encoded images) or can I send you a zip file? – billmalarky May 21 '14 at 22:40
If you're on ruby there is a gem based on libreoffice headless (with pyod/jod converter) and pdf tools.

- 3,199
- 31
- 48

- 900
- 6
- 16
Post with your issues to the pandoc GoogleGroup, John is very responsive in every way.
You may even find the latest release v1.9 may fix your problem, or maybe you just need to get to know the toolset in more detail.

- 486
- 4
- 4
I found soultion - is abiword in console variant.

- 533
- 2
- 4
- 15
-
How does this add to [this more elaborate answer](https://stackoverflow.com/a/8384078/4575793)? – Cadoiz Sep 07 '22 at 12:11