PHP HTML to DOC

525 views Asked by At

I'm using the following to convert a html file to doc.

The following example works great and it does exactly what it should, but I have another document, but in this document I use mainly <div>s and not tables. It seems that the conversion or fooling of word does not work when using divs.

Am I right? The content of the document comes through, but the layout and style is completely shot to pieces.

Running the div doc as a normal html file look perfect.

any ideas please.

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: vnd.ms-word");
header("Content-Disposition: attachment; filename='DischargeLetter.doc'");
header("Content-Transfer-Encoding: binary ");

$text = "$text="<style type='text/css'>
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg .tg-uhkr{background-color:#ffce93}
.tg .tg-wsnc{background-color:#fffc9e}
.tg .tg-glis{font-size:10px}
.tg .tg-7khl{font-size:15px}
.tg .tg-3sk9{font-weight:bold;font-size:12px}
.tg .tg-jzyw{font-weight:bold;font-size:13px}
</style>
<table class='tg'>
  <tr>
    <th class='tg-uhkr' colspan='3'>Logo<br>thaaf<br>la;sdkhf;ls<br>a;slkdhals</th>
    <th class='tg-uhkr' colspan='3''>Address</th>
  </tr>
  <tr>
    <td class='tg-3sk9'>1st Col</td>
    <td class='tg-glis'>2nd col</td>
    <td class='tg-glis'>3rd col</td>
    <td class='tg-jzyw'>4th col</td>
    <td class='tg-glis'>5th col</td>
    <td class='tg-glis'>6th col</td>
  </tr>
  <tr>
    <td class='tg-wsnc' colspan='6'>Row</td>
  </tr>
  <tr>
    <td class='tg-7khl' colspan='2'>1 of 3</td>
    <td class='tg-031e' colspan='2'>2 of 3</td>
    <td class='tg-031e' colspan='2'>3 of 3</td>
  </tr>
</table>";




echo $text;
0

There are 0 answers