1

How do I properly use dompdf to convert html files into 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

<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>
3
  • I was update my answer. You can check. Commented Jan 28, 2011 at 15:59
  • Your html is still horribly structured. dompdf is somewhat flexible in dealing with structural problems, but not that much. The following document (based on your own) will render correctly: eclecticgeek.com/dompdf/debug_tests/so4829828.htm Commented Feb 2, 2011 at 18:55
  • if i wants to use a url then wht is the code updation. ??? Commented Jun 13, 2013 at 12:14

1 Answer 1

4

checkout.html is valid ? Is there any table and unclosed tags ?

There was an answer on Google Groups :

  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

  2. check for table-related display types in your CSS on elements where the table structure hasn't been explicitly outlined

UPDATE :

Your checkout.html file ISN'T valid. 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

Your comment block isn't closed. You can use this line :

<!--<th>Discount</th>--><!-- commented out jan 21--> 
Sign up to request clarification or add additional context in comments.

6 Comments

tried removing all of those comments but still it says the same kind of error.
can you try adding <html> , <head> tags etc. And check validator.w3.org/check
th elements should still be in a tr; h3 element inside the table but not in a td; some rows have 13 cells, some have only 9 (though I don't think this last will cause any problem)
@PuzzledBoy , just get content of your url (like file_get_contents($url)and than use $dompdf->load_html($content) instead of $dompdf->load_html_file($url) . It should work.
@Eray Sir i have tried but not solving the issue.. My problem is here stackoverflow.com/questions/17086731/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.