gpt4 book ai didi

php - DomPDF 错误未捕获异常 'Dompdf\Exception'

转载 作者:行者123 更新时间:2023-11-28 01:28:11 24 4
gpt4 key购买 nike

我的 DOMPDF 有问题。

我正在尝试使用 DOMPDF 生成一个表格。

错误信息:

The row #1 could not be found

完整的错误报告:

>     Fatal error: Uncaught exception 'Dompdf\Exception' with message 'The row #1 could not be found, please file an issue in the tracker
> with the HTML code' in /var/www/dompdf/src/Cellmap.php:415 Stack
> trace: #0 /var/www/dompdf/src/FrameReflower/TableRow.php(62):
> Dompdf\Cellmap->get_frame_height(Object(Dompdf\FrameDecorator\TableRow))
> #1 /var/www/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(894):
> Dompdf\FrameReflower\TableRow->reflow(NULL) #2
> /var/www/dompdf/src/FrameReflower/TableRowGroup.php(51):
> Dompdf\FrameDecorator\AbstractFrameDecorator->reflow() #3
> /var/www/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(894):
> Dompdf\FrameReflower\TableRowGroup->reflow(NULL) #4
> /var/www/dompdf/src/FrameReflower/Table.php(489):
> Dompdf\FrameDecorator\AbstractFrameDecorator->reflow() #5
> /var/www/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(894):
> Dompdf\FrameReflower\Table->reflow(Object(Dompdf\FrameDecorator\Block))
> #6 /var/www/dompdf/src/FrameReflower/Block.php(845): Dompdf\FrameDecorator\AbstractFrameDecorator->reflo in
> /var/www/dompdf/src/Cellmap.php on line 415

这是我的HMTL

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="styles.css">
<title>Rechnung</title>
</head>
<footer>Footer on every page</footer>
<header>
<img src="lib/gfx/xx.jpg" style="width: 30%; float:left;" alt="xx">
<p style="width: 30%; float:right; margin-right: 5px;">
xxxx xxxx GmbH
<br>XXXX xx
<br>XXX XXX
<br>Deutschland
</p>
</header>
<body>
<main>
<div class="ueberschrift">Rechnung</div>
<table id="table">
<thead class="thead-dark">
<tr class="tr-head">
<div class="border-line-bottom">
<th scope="col" class="th-head">Stückzahl</th>
<th scope="col" class="th-head">Preis</th>
<th scope="col" class="th-head">Artikel</th>
</div>
</tr>
</thead>
<tbody>
<tr class="tr-body">
<td class="td-body">1</td>
<td class="td-body">12</td>
<td class="td-body">23</td>
</tr>
</tbody>
</table>
</main>
</body>
</html>

这是我的 CSS

@page
{
margin: 100px 25px;
}

header {
position: fixed;
top: -60px;
left: 0px;
right: 0px;
height: 100px;
border-bottom: 1px solid black;
}

footer {
position: fixed;
bottom: -60px;
left: 0px;
right: 0px;
height: 50px;
}

p {
page-break-after: always;
}

p:last-child {
page-break-after: never;
}

.ueberschrift {
margin-top: 10%;
display: block;
margin-left: 45%;
font-size: 20px;
font-weight: bold;
}

#table {
width: 100%;
}

.thead-dark {
color: black;
width: 100%;
}

.th-head {
display: inline-block;
margin-left: -20%;
}

#table .thead-dark th:nth-child(1) {
display: inline-block;
margin-left: 20px;
}

#table .thead-dark th:nth-child(2) {
display: inline-block;
margin-left: 90px;
}

#table .thead-dark th:nth-child(3) {
display: inline-block;
margin-left: 170px;
}

/*
CSS für die Werte -> td
*/

#table .tr-body td:nth-child(1) {
display: inline-block;
margin-left: 20px;
}


#table .tr-body td:nth-child(2) {
display: inline-block;
margin-left: 90px;
}

#table .tr-body td:nth-child(3) {
display: inline-block;
width: 10%;
background: red;
}

.border-line-bottom {
width: 90%;
margin: 0 auto;
border-bottom: 1px solid black;
}

我觉得问题可能出在显示:内联 block #table .tr-body td:nth-child(3)当我删除显示标签时,它可以正常工作。

感谢帮助

最佳答案

尝试删除 display: inline-block;来自 CSS 中的 th 和 td。并删除不必要的 <div class="border-line-bottom">来自 thead正如@FatFreddy 在他的回答中所说。

当您用值 inline-block 覆盖 th/td 显示时表中的 css 不是您期望的行为。

关于php - DomPDF 错误未捕获异常 'Dompdf\Exception',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51134499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com