Convert html with image to ms.word
Posted
by
user1629258
on Stack Overflow
See other posts from Stack Overflow
or by user1629258
Published on 2012-09-04T03:35:27Z
Indexed on
2012/09/04
3:37 UTC
Read the original article
Hit count: 114
I have the html code as below:
file.html
<body>
<h1>TEST</h1>
<p>this is test</p>
<table>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td><img src="../../../wamp/www/html2doc/SGEPP.jpg"></td>
</tr>
</table>
html2doc.php
<?php
$handle = fopen("doc2html.html","r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=html2word.doc");
echo $contents;
?>
The problems:
when I convert it,I get html2word.doc but I can get only all texts from html file.For the images in html file I can not get it, it is missing images.So I want to get all data from html and images also.How do I fix this?Anyone help me please,Thanks.
© Stack Overflow or respective owner