Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert HTML file to word? [closed]

Tags:

html

ms-word

I 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 language I'm using in order to narrow down the choices.

like image 806
Mask Avatar asked Oct 26 '09 12:10

Mask


People also ask

Can I edit an HTML file in Word?

If you are a Microsoft Word user, you can still edit HTML files in Word, just as you would any other text-based file. This permits you to directly edit and change a HTML file without the use of a more expensive Web authoring tool.


2 Answers

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 
like image 157
Jan Avatar answered Oct 04 '22 03:10

Jan


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.

like image 26
SAR Avatar answered Oct 04 '22 04:10

SAR