How to convert HTML file to word? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this questionI need to save HTML documents in memory as Word .DOC files.
Can anybody give me some links to both closed and open source libraries that I can use to do this?
Also, I should edit this question to add the lan开发者_如何学Cguage I'm using in order to narrow down the choices.
Try using pandoc
pandoc -f html -t docx -o output.docx input.html
If the input or output format is not specified explicitly, pandoc will attempt to guess it from the extensions of the input and output filenames.
— pandoc manual
So you can even use
pandoc -o output.docx input.html
just past this on head of your php page. before any code on this should be the top code.
<?php
header("Content-Type: application/vnd.ms-word");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=Hawala.doc");
?>
this will convert all html to MSWORD, now you can customize it according to your client requirement.
A good option is to use an API like Docverter. Docverter will allow you to convert HTML to PDF or DOCX using an API.
When doing this I found it easiest to:
- Visit the page in a web browser
- Save the page using the web browser with .htm extension (and maybe a folder with support files)
- Start Word and open the saved htmfile (Word will open it correctly)
- Make any edits if needed
- Select Save As and then choose the extension you would like doc, docx, etc.
Other Alternatives from just renaming the file to .doc.....
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word(office.11).aspx
Here is a good place to start. You can also try using this Office Open XML.
http://www.ecma-international.org/publications/standards/Ecma-376.htm
精彩评论