Question

I want to create report in doc file this will include images and table. I wrote a following code

<?php
@header("Cache-Control: ");// leave blank to avoid IE errors
@header("Pragma: ");// leave blank to avoid IE errors
@header('Content-Description: File Transfer');
@header("Content-type: application/vnd.ms-word");
@header("Content-Disposition: attachment; filename=report.doc");
?>

<img src="http://l1.yimg.com/dh/ap/default/130613/fruit-chaat.jpg" border="0" style="border:none">
<br>
<table style="border:2;background-color:red;">
<?php 
$arr = array();
$arr = array(1,2,3,4,5,);
foreach($arr as $row=>$value){  ?>
    <tr><td>First <?php echo $value; ?></td>
    </tr>
<?php } ?>
</table>

But It write image from a location if that location is not reachable that image will not display in document file. I used to embed image but this embeds code instead of image. Please suggest some solutions. Is there any other way to doIt. I know about Com object but it works only on window. I am doing development on linux server.

Was it helpful?

Solution

Finally I solved this problem using OpenTBS Created a template file with header, footer, images and place holders. Place holders I replaced with dynamic values. Like $reporttitle is defined in demo_ms_word.php and created a place holder as below [onshow.reportsubtitle].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top