Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandoc convert html with style sheet to docx

I've been banging my head on this one for a few hours, and I'm sure the solution is quite simple, or non-existent.

I'm trying to convert an html file to docx!

<!DOCTYPE html>
<html>
<head>
<style>
body {
    background-color: #d0e4fe;
}

h1 {
    color: orange;
    text-align: center;
}

p {
    font-family: "Times New Roman";
    font-size: 20px;
}
</style>
</head>
<body>

<h1>My First CSS Example</h1>
<p>This is a paragraph.</p>

</body>
</html>

I can convert it no problem, but I can't get the styles to stick.

pandoc -s myfile.html -o test64.docx
pandoc -s -c myfile.css myfile.html -o test64.docx

Please save me.

like image 477
l2silver Avatar asked Apr 07 '15 03:04

l2silver


People also ask

Can pandoc convert HTML to Markdown?

Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.

Can pandoc convert PDF to Word?

You can use the program pandoc on the SCF Linux and Mac machines (via the terminal window) to convert from formats such as HTML, LaTeX and Markdown to formats such as HTML, LaTeX, Word, OpenOffice, and PDF, among others.


1 Answers

The above answer no longer works. According to the documentation, you now produce the template using:

pandoc --print-default-data-file reference.docx > custom-reference.docx

For the full documentation of how to use the template, go to the documentation and search for "--reference-doc"

like image 197
satnam Avatar answered Oct 18 '22 03:10

satnam