Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert html to docx using pandoc

Tags:

pandoc

I trying to convert this html

<p><font color = \"#808080\">SHILPI</p>

to docx using pandoc with this command

pandoc -s -o "test.docx" -t html5 -t docx html_file

But its losing colors, I am getting only text, as far as I know I think html code is correct because when I am using wkhtmltopdf to convert same html to pdf it gives the proper color. What can be the issue ? Thanks in advance.

like image 627
Shilpi Agrawal Avatar asked Dec 15 '22 11:12

Shilpi Agrawal


1 Answers

That's not how Pandoc works, it doesn't understand CSS, only HTML/Markdown. It preserves the content, but not the layout etc, see semantic HTML.

You can, however, use templates to style your output consistently. With Word it's a bit more complicated but you can use the --reference-doc option for mostly the same effect.

like image 70
mb21 Avatar answered Mar 20 '23 08:03

mb21