简体   繁体   English

使用dompdf将html文件转换为pdf

[英]convert html file to pdf using dompdf

How do I properly use dompdf to convert html files into pdf. 如何正确使用dompdf将html文件转换为pdf文件。 I'm doing something like this: 我正在做这样的事情:

<?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");

?>

But I get this error: 但我得到这个错误:

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

How do I solve this, please enlighten me. 我该如何解决这个问题,请赐教。 Thanks. 谢谢。

Update Here are the contents of checkout.html 更新以下是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>

checkout.html is valid ? checkout.html有效吗? Is there any table and unclosed tags ? 有没有桌子和未封闭的标签?

There was an answer on Google Groups : Google网上论坛有一个答案:

  1. check to see if you have any unclosed tags within the the table; 检查表中是否有任何未关闭的标签; DOMPDF can have trouble when your HTML isn't well-formed 当HTML格式不正确时,DOMPDF会遇到麻烦

  2. check for table-related display types in your CSS on elements where the table structure hasn't been explicitly outlined 检查CSS中与表结构尚未明确概述的元素上的表相关显示类型

UPDATE : 更新:

Your checkout.html file ISN'T valid. 您的checkout.html文件无效。 There is a problem : 有一个问题 :

<!--<th>Discount</th><!-- commented out jan 21--> 

Line 5, Column 31: invalid comment declaration: found name start character outside comment but inside comment declaration 第5行,第31列:无效的注释声明:在注释之外找到名称开始字符但在注释声明中

Your comment block isn't closed. 您的评论栏未关闭。 You can use this line : 你可以使用这一行:

<!--<th>Discount</th>--><!-- commented out jan 21--> 

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

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