1
如何正確使用dompdf將html文件轉換爲pdf。我在做這樣的事情:使用dompdf將html文件轉換爲pdf
<?php
require_once("lib/dompdf/dompdf_config.inc.php");
$file = "checkout.html";
$dompdf = new DOMPDF();
$dompdf->load_html_file($file);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
但我得到這個錯誤:
Fatal error: Call to undefined method Inline_Frame_Decorator::normalise() in C:\wamp\www\pos\php\lib\dompdf\include\table_frame_decorator.cls.php on line 252
我該如何解決這個問題,請賜教。謝謝。
更新 這裏是checkout.html的內容
<table border="0">
<th colspan="10">Product</th>
<th>Quantity</th>
<th>Price</th>
<!--<th>Discount</th><!-- commented out jan 21-->
<th>Subtotal</th>
<!-- fetch values from reports and prod_table using the qtysoldfetcher query-->
<tr>
<td colspan="10">Boysen</td>
<td>4</td>
<td>900</td>
<!-- <td></td> --><!-- commented out jan 21-->
<td>3600</td>
</tr>
<h3 id="wyt">Sales Transaction Summary</h3><a href="pdfqtysold.php"><img id="tablez" src="../img/system/icons/Oficina-PDF-icon.png"></img></a>
<tr>
<td>Total Bill: </td>
<td colspan="8">3600</td>
<!--added jan 19 -->
</tr>
<tr>
<td>Amount paid: </td>
<td colspan="8">900</td>
</tr>
<tr>
<td>Change: </td>
<td colspan="8"></td>
</tr>
<tr>
<td>Credit: </td>
<td colspan="8">2700</td>
</tr>
<tr>
<td>Date: </td>
<td colspan="8">2011-01-28 11:13:52</td>
</tr>
<tr>
<td>Bought by: </td>
<td colspan="8">Asakura, Yoh</td>
</tr>
<!--end-->
</table>
我更新了我的答案。你可以檢查。 – Eray 2011-01-28 15:59:11
你的html仍然是可怕的結構。 dompdf在處理結構問題時有一定的靈活性,但不是*那麼多。以下文檔(基於您自己的)將正確呈現:http://eclecticgeek.com/dompdf/debug_tests/so4829828.htm – BrianS 2011-02-02 18:55:08