title: Convert HTML table into a text file without losing format
body: <p>I am unable to find any post which has answer to my issue.</p>
  
  <p>I have html file which has a table, need to convert this to a text file without losing the format USING php script, as it has to be printed as is on a dotmatrix printer.</p>
  
  <p>OR if there is any other way of doing this, pl suggest !</p>
  
  <p>The table is a Invoice format, pl see below:</p>
  
  <pre><code>&lt;table width='100' height='300' border='0' cellspacing='0' cellpadding='1'&gt;  &lt;tr&gt;    &lt;td&gt;&lt;img src='spacer.jpg' width='100' height='1'&gt;&lt;/td&gt;    &lt;td&gt;&lt;table width='840' border='1' cellspacing='2' cellpadding='0'&gt;&lt;tr&gt;&lt;td width='660' colspan='2' valign='top'&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Customer Name: 3M India Ltd&lt;br&gt;
      Address:Plat 48-51 Electronic City&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;td width='180' valign='top'&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
  Inv No: 78788&lt;br&gt;&lt;br&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;20/04/2012&amp;nbsp;12:28:18&lt;br&gt;&lt;br&gt; 
  &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td width='292' valign='top'&gt;DC Nos: 500,&amp;nbsp;    &lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;td valign='top'&gt; Your Order No.: 322&lt;br&gt;
         C.E.Reg No.: &lt;br&gt;
         Vehicle No.: KA-01-N-2345&lt;br&gt;&lt;td valign='top'&gt; Party:&lt;br&gt;
  TIN: 29400127541&lt;br&gt;
  CST: 29400127541&lt;br&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan='2'&gt;Sl No. &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Description &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Tariff Code &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Rate &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Qty &lt;/td&gt;    &lt;td&gt;Amount&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan='3'&gt;     &lt;table width='840' height='160' border='0' cellspacing='1' cellpadding='0'&gt;     &lt;tr valign='top'&gt;       &lt;td width='87'&gt;1&lt;/td&gt;       &lt;td width='247'&gt;Argon&lt;/td&gt;      &lt;td width='165'&gt;AR1223&lt;/td&gt;     &lt;td width='92'&gt;120&lt;/td&gt;     &lt;td width='67'&gt;1&amp;nbsp;Nos&lt;/td&gt;      &lt;td width='182'&gt;120.00&lt;/td&gt;     &lt;/tr&gt;       &lt;/table&gt;    &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt; &lt;td colspan='2' valign='top'&gt;&lt;div align='right'&gt;&lt;br&gt;VAT: &amp;nbsp;5.00 %&lt;br&gt;Demurrage: &lt;br&gt;   Freight:  &lt;br&gt;&lt;br&gt;    &lt;/div&gt;Rupees Four Hundred &amp; Fourty One    Only.&lt;/td&gt;&lt;td valign='top'&gt;&lt;br&gt; 21.00&lt;br&gt; 0.00&lt;br&gt; 300.00&lt;br&gt;&lt;br&gt; &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan='2' valign='top'&gt;&lt;div align='right'&gt;Total:&lt;br&gt;&lt;br&gt;Rounded Off&lt;/div&gt;&lt;/td&gt;    &lt;td valign='top'&gt;441.00&lt;br&gt;&lt;br&gt;441.00&lt;br&gt;&lt;br&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;    &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;
  </code></pre>