I am trying to convert a HTML
content to a doc
file using PHP. I am following this tutorial.
Everything works fine when I export only textual data. But when I try to export an image file, like:
<?php
include_once 'html_to_doc.php';
$htmlContent = '<h1 style="text-align: center; color: rgb(50, 91, 205); font-size: 35px;">
<u>TITLE</u></h1>
<div style="text-align:center";><table style="background-color:rgb(81, 205, 50); border: 2px solid black;">
<tr>
<td style="border: 1px solid black;">
<img src="/image.jpg" width="150" height="150">
</td>
<td style="border: 1px solid black;">
<img src="/new_image.jpg" width="150" height="150">
</td>
<td style="border: 1px solid black; text-align:center">
<div style="background-color:rgb(148, 76, 17); width:100%; padding:5px; color: white; font-weight: bold;">20/03/2021</div><br>
<div style="background-color:rgb(20, 104, 104); padding:5px; color: white; font-style: italic; font-weight: bold;">Exclusive</div>
</td>
</tr>
</table></div><br>';
$htd = new HTML_TO_DOC();
$htd->createDoc($htmlContent, "word_file",1);
?>
There's a cross (X) mark in place of the image, in the doc
file, even when the image url is correct. Where am I going wrong? Please help me.
When I try to print the image directory
echo __DIR__.'/image.jpg';
and go to the link, the image shows. That means the image url is correct. So why isn't it being rendered in my word file?