以下内容:
在单元格映射中找不到框架
https://github.com/dompdf/dompdf/issues/657
是互联网上众所周知的问题。但是我找不到解决方案对于问题。我正在尝试将我的 html 模板转换为 pdf。当我删除<table>
时,它正在工作。否则,它会引发异常。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example 2</title>
<link rel="stylesheet" href="/administration/style.css" media="all" />
</head>
<body>
<header class="clearfix">
<div id="logo">
<img src="/administration/logo.png">
</div>
<div id="company">
<h2 class="name">Company Name</h2>
<div>455 Foggy Heights, AZ 85004, US</div>
<div>(602) 519-0450</div>
<div><a href="mailto:company@example.com">company@example.com</a></div>
</div>
</div>
</header>
<main>
<div id="details" class="clearfix">
<div id="client">
<div class="to">INVOICE TO:</div>
<h2 class="name">John Doe</h2>
<div class="address">796 Silver Harbour, TX 79273, US</div>
<div class="email"><a href="mailto:john@example.com">john@example.com</a></div>
</div>
<div id="invoice">
<h1>INVOICE 3-2-1</h1>
<div class="date">Date of Invoice: 01/06/2014</div>
<div class="date">Due Date: 30/06/2014</div>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="no">#</th>
<th class="desc">DESCRIPTION</th>
<th class="unit">UNIT PRICE</th>
<th class="qty">QUANTITY</th>
<th class="total">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td class="no">01</td>
<td class="desc"><h3>Website Design</h3>Creating a recognizable design solution based on the company's existing visual identity</td>
<td class="unit">$40.00</td>
<td class="qty">30</td>
<td class="total">$1,200.00</td>
</tr>
<tr>
<td class="no">02</td>
<td class="desc"><h3>Website Development</h3>Developing a Content Management System-based Website</td>
<td class="unit">$40.00</td>
<td class="qty">80</td>
<td class="total">$3,200.00</td>
</tr>
<tr>
<td class="no">03</td>
<td class="desc"><h3>Search Engines Optimization</h3>Optimize the site for search engines (SEO)</td>
<td class="unit">$40.00</td>
<td class="qty">20</td>
<td class="total">$800.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="1"></td>
<td colspan="1">SUBTOTAL</td>
<td>$5,200.00</td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="1">TAX 25%</td>
<td>$1,300.00</td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="1">GRAND TOTAL</td>
<td>$6,500.00</td>
</tr>
</tfoot>
</table>
<div id="thanks">Thank you!</div>
<div id="notices">
<div>NOTICE:</div>
<div class="notice">A finance charge of 1.5% will be made on unpaid balances after 30 days.</div>
</div>
</main>
<footer>
Invoice was created on a computer and is valid without the signature and seal.
</footer>
</body>
</html>
我遇到了类似的问题,但能够发现我的一个文本项目中有一个额外的<
(文本是由用户输入的,所以他们有一个年龄问题,就像Are you < 21 years old
一样。 确保你转义了这些(在 PHP 中,使用 htmlentities
)。
无效的 html 或额外的 HTML 标记也可能发生这种情况。 我浏览了上面的<table>
并通过dompdf运行它,但它没有抛出错误,所以也许你的代码中有一个错误的<
没有复制到StackOverflow?
我遇到了同样的问题,并解决了从表格中删除html标签的问题,例如<thead>
,<tbody>
和 <tfoot>
。我希望它对你有所帮助。
解决方案:
使用这个:
$orientation = 'landscape';
$customPaper = array(0,0,950,950);
$this->setPaper($customPaper, $orientation);