DomPDF错误未捕获的异常'Dompdf \ Exception' [英] DomPDF Error Uncaught exception 'Dompdf\Exception'

查看:53
本文介绍了DomPDF错误未捕获的异常'Dompdf \ Exception'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 DOMPDF 有问题.

我正在尝试使用 DOMPDF 生成表.

I'm trying to generate a table with DOMPDF.

错误消息:

找不到行#1

完整的错误报告:

>     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;
}

我认为问题可能出在显示:内联屏蔽 #table .tr-body td:nth-​​child(3)当我移除展示广告代码时,它可以正常工作.

I think the problem might be the display: inline-block at #table .tr-body td:nth-child(3) When i remove the display tag it works without a problem.

感谢帮助

推荐答案

尝试从CSS的th和td中删除 display:inline-block; .并按照@FatFreddy在回答中所说的,从 thead 中删除不必要的< div class ="border-line-bottom"> .

Try to remove the display: inline-block; from the th and the td in your CSS. And remove the unnecessary <div class="border-line-bottom"> from the thead as @FatFreddy said in his answer.

当您用值 inline-block 覆盖th/td显示时,表中的css不是您想要的行为.

When you overwrite the th/td display with the value inline-block the css from the table is not the behavior as you want to expect.

这篇关于DomPDF错误未捕获的异常'Dompdf \ Exception'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆