DomPDF 的 get_cellmap() 问题

问题描述 投票:0回答:7

我正在使用 DomPdf 并尝试将我的文件转换为 pdf,但遇到下面给出的奇怪错误

我用谷歌搜索了很多次并阅读了不同的论坛,但没有得到这个错误的原因。

请大家帮助我。

致命错误:未捕获错误:调用成员函数 get_cellmap() 在空值上 C:\xampp\htdocs\dom\dompdf\src\FrameReflower\TableCell.php:37 堆栈 跟踪:#0 C:\ xampp \ htdocs \ dom \ dompdf \ src \ FrameDecorator \ AbstractFrameDecorator.php(893): Dompdf\FrameReflower\TableCell->回流(NULL) #1 C:\xampp\htdocs\dom\dompdf\src\FrameReflower\TableRow.php(52): Dompdf\FrameDecorator\AbstractFrameDecorator->reflow() #2 C:\ xampp \ htdocs \ dom \ dompdf \ src \ FrameDecorator \ AbstractFrameDecorator.php(893): Dompdf\FrameReflower\TableRow->回流(NULL) #3

代码

require_once './dompdf/autoload.inc.php';
use Dompdf\Dompdf;

$dompdf = new Dompdf();
$dompdf->loadHtml(file_get_contents('./my-file.php'));

$dompdf->setPaper('A4','landscape');
$dompdf->render();

$dompdf->stream('codexworld',array('Attachment'=>0));

我的文件.php

<!DOCTYPE html>
<html>

<head>
</head>

<body>

<div id="page-wrap">
<form method="post" action="save_view.php" novalidate="">   

<div id="header">

<h2 class="title" style="text-decoration: underline;font-size:2em;font-family: Brush Script Mt;">Pro Tech Diagnostics</h2>
<!--            <img id="image"  width="auto" src="images/Logo.png" alt="logo" height="60"/>-->
<div  class="adjust_contact">
<p>26893 Bouquet Canyon Rd. Suite C204 Saugus, CA 91350</p>
<div class="parent">

<p class="left">Phone # (818)644-1965</p>
<p class="right">Fax # (661) 468-7504</p>
</div>
</div>
</div>

<div id="identity">



<div id="header1">

<h3>Customer Info</h3>
</div>

</div>


<div style="clear:both"></div>


<!--            <textarea id="customer-title">Widget Corp.
c/o Steve Widget</textarea>-->

<div id="customer"> 
<div id="parent">

<table id="meta" style="overflow: wrap" class="left1">

<tr>
<td class="meta-head">Name</td>
<td>
<input name="name" type="text"/>

</td>
</tr>

<tr>
<td class="meta-head">Address</td>
<td>
<input name="address" type="text"/>

</td>
</tr>
<tr>
<td class="meta-head">Phone</td>
<td>
<input  required="required" name="phone" type="text"/>

</td>
</tr>                


</table>



<table id="meta" style="overflow: wrap" class="right1">


<tr>
<td class="meta-head">Invoice#</td>
<td>
<input  required="required" name="invoice" type="text"/>

</td>
</tr>                

<tr>

<td class="meta-head">Paid Date</td>
<td>
<input  required="required" name="date" type="text"/>
</td>
</tr>


</table>                    
</div>
</div>


<!-----------------------3 columns Table Section------------------------->

<div id="identity">
<div id="header1-1">

<h3>Vehicle Info</h3>
</div>

</div>

<div class="Row">
<div class="Column">
<table id="meta" style="overflow: wrap" class="left1">

<span class="parent">
<tr>
<td class="meta-head">Make:</td>
<td>
<input  required="required" name="make" type="text"/>

</td>
</tr>

<tr>
<td class="meta-head">Model:</td>
<td>
<input  required="required" name="model" type="text"/>

</td>
</tr>
</span>
<tr>
<td class="meta-head">Year:</td>
<td>
<input  required="required" name="year" type="text"/>

</td>
</tr>                


</table>    

</div><!--1st table-->


<div class="Column">
<table id="meta" style="overflow: wrap" class="left1">

<span class="parent">
<tr>
<td class="meta-head">Vin #:</td>
<td>
<input  required="required" name="vin" type="text"/>

</td>
</tr>

<tr>
<td class="meta-head">Lic.#:</td>
<td>
<input  required="required" name="lic" type="text"/>

</td>
</tr>
</span>
<tr>
<td class="meta-head">Miles:</td>
<td>
<input  required="required" name="miles" type="text"/>

</td>
</tr>                


</table>
</div><!--2nd table-->

<div class="Column">

<table id="meta" style="overflow: wrap" class="left1">

<span class="parent">
<tr>
<td class="meta-head">Color:</td>
<td>
<input  required="required" name="color" type="text"/>

</td>
</tr>

<tr>
<td class="meta-head">R.O. #:</td>
<td>
<input  required="required" name="ro" type="text"/>

</td>
</tr>
</span>
<tr>
<td class="meta-head">P.O. #:</td>
<td>
<input  required="required" name="po" type="text"/>

</td>
</tr>                


</table>
</div><!--3rd table-->

</div><!--End 3 column table row-->






<table id="items" style="overflow: wrap; margin-top: 100px;">

<tr>
<th  colspan="6">Descryption</th>

<th>Hrs</th>
<th colspan="1">Amount</th>
</tr>

<tr class="item-row">
<td colspan="6" class="item-name">
<textarea style="padding-bottom: 300px;" name="description" rows="12" cols="5"></textarea>
<p style="font-weight: bold">*******All Parts Supplied By Shop*******</p>
</td>


<td>
<input  name="hrs" type="text"/>

</td>

<td colspan="5">

<input required="required" name="amount" type="text"/>
</td>
</tr>


<tr>
<td colspan="4">Technician #: 81 (Miguel A.)</td>
<td style="border: none;" colspan="2">Labor Hrs:</td>
<td colspan="1"><input placeholder="0"  name="labourHrs" type="text"/></td>
<td colspan="1"></td>
</tr>

<tr>
<td colspan="2">Labor Rate (Per Hr):</td>
<td  colspan="2"><input placeholder="60" required="required" name="labourRate" type="text"/></td>
<td style="border: none;" colspan="2">Labor Price:</td>
<td colspan="1"><input placeholder="0"  name="labourPrice" type="text"/></td>
<td colspan="1"></td>
</tr>

<tr>
<td style="border: none;" colspan="4"></td>
<td style="border: none;" colspan="2">Total</td>
<td colspan="1"></td>
<td colspan="1"><input  placeholder="0"  name="total" type="text"/></td>
</tr>

<tr>
<td style="border: none" colspan="4"></td>
<td colspan="3">Grand Total</td>
<td colspan="1"><input  placeholder="$0.00"  name="gTotal" type="text"/></td>
</tr>


<tr>
<td colspan="4">Signature Approval:</td>
<td colspan="4"></td>
</tr>

<tr>
<td style="border: none" colspan="4"></td>
<td style="border-right: none;" colspan="4">Paid</td>
</tr>

<tr class="no-border">
<td colspan="4"></td>
<td></td> 
<td >Yes<input type="checkbox" name="one" value="Yes( &#10003; )"></td>
<td>No ( )<input type="checkbox" name="two" value="No( &#10003; )"></td>
<td>P.O. ( )<input type="checkbox" name="three" value="P.O( &#10003; )"></td>
</tr>

<tr>

<td colspan="8">
<p style="font-size: 10px">Not responsible for loss by fire or theft or any other cause beyond our control. I hereby authorize the above repair work to be done with the necessary material & grant
permission to operate equipment for purpose of testing and inspection. An express mechanic's lien is acknowledged to secure the amount of repairs. I agree to pay
the payment in full no later than 30 days after work has been completed. After 30 days, a 1.4% monthly charge will be added to the outstanding balance.
</p>
</td>
</tr>


</table>


</div>
<h2 style="text-decoration: underline;font-style: italic;text-align: center; font-weight: bold;font-family: Brush Script Mt;">
Thanks for Your Business
</h2>
<input name="submit" class="submit" type="submit" value="Submit"/>

</form>

</body>

</html>
php pdf dompdf
7个回答
8
投票

DomPDF 与 CSS 属性发生冲突,例如

display
我不知道为什么,但尝试删除
display
属性


5
投票

如果您正在使用 table 并且遇到这个问题,那么 有两个对我有用的技巧。 我不知道这个技巧是否是正确的解决方案。

  1. 检查表格内所有
    td
    中的
    tr
    数量应相同。
  2. 如果您使用过
    tfooter
    ,请移除
    tfooter
    并将其放入
    tr
    内。
    
    
  3. 它可能对你有帮助。


1
投票

tbody

之后:

<thead> <tr> ... </tr> </thead> ...

为我工作。 我没有发现,因为数据很少(10)工作正常,但数据更多(15-20)它返回了这个错误


0
投票


0
投票


0
投票


-1
投票

© www.soinside.com 2019 - 2024. All rights reserved.