简体   繁体   English

将HTML表转换为文本文件而不丢失格式

[英]Convert HTML table into a text file without losing format

I am unable to find any post which has answer to my issue. 我找不到任何可以回答我问题的帖子。

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. 我有带有表的html文件,需要将其转换为文本文件而不丢失使用php脚本的格式,因为它必须在dotmatrix打印机上按原样打印。

OR if there is any other way of doing this, pl suggest ! 或者,如果还有其他方法,请建议!

The table is a Invoice format, pl see below: 该表是发票格式,请参见以下内容:

<table width='100' height='300' border='0' cellspacing='0' cellpadding='1'>  <tr>    <td><img src='spacer.jpg' width='100' height='1'></td>    <td><table width='840' border='1' cellspacing='2' cellpadding='0'><tr><td width='660' colspan='2' valign='top'><br><br><br><br><br><br><br><br><br>Customer Name: 3M India Ltd<br>
    Address:Plat 48-51 Electronic City<br><br></td><td width='180' valign='top'><br><br><br><br><br><br><br><br><br>
Inv No: 78788<br><br>Date:&nbsp;&nbsp;&nbsp;20/04/2012&nbsp;12:28:18<br><br> 
</td>  </tr>  <tr>    <td width='292' valign='top'>DC Nos: 500,&nbsp;    <br><br></td><td valign='top'> Your Order No.: 322<br>
       C.E.Reg No.: <br>
       Vehicle No.: KA-01-N-2345<br><td valign='top'> Party:<br>
TIN: 29400127541<br>
CST: 29400127541<br></td>  </tr>  <tr>    <td colspan='2'>Sl No. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Description &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tariff Code &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rate &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Qty </td>    <td>Amount</td>  </tr>  <tr>    <td colspan='3'>     <table width='840' height='160' border='0' cellspacing='1' cellpadding='0'>     <tr valign='top'>       <td width='87'>1</td>       <td width='247'>Argon</td>      <td width='165'>AR1223</td>     <td width='92'>120</td>     <td width='67'>1&nbsp;Nos</td>      <td width='182'>120.00</td>     </tr>       </table>    </td>  </tr>  <tr> <td colspan='2' valign='top'><div align='right'><br>VAT: &nbsp;5.00 %<br>Demurrage: <br>   Freight:  <br><br>    </div>Rupees Four Hundred & Fourty One    Only.</td><td valign='top'><br> 21.00<br> 0.00<br> 300.00<br><br> </td>  </tr>  <tr>    <td colspan='2' valign='top'><div align='right'>Total:<br><br>Rounded Off</div></td>    <td valign='top'>441.00<br><br>441.00<br><br></td>  </tr></table>    </td>  </tr></table>

Could you not open the HTML file in something like Microsoft Word and then send it to print? 您是否无法在Microsoft Word之类的文件中打开HTML文件,然后将其发送以进行打印?

You could also convert the HTML file to PDF, there's several free ones (Google "html to pdf conversion") as another option to see if it works. 您还可以将HTML文件转换为PDF,还有一些免费的文件(Google将“ html转换为pdf”),以查看其是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM