简体   繁体   English

domPDF-如果表格达到页面高度,表格总是会移至底部

[英]domPDF - Table always going to bottom if reaching page height

I'm using DOMPDF to generating PDF files but I have a little problem. 我正在使用DOMPDF生成PDF文件,但是有一个小问题。
Here is my basic table for this template: 这是此模板的基本表格:

<!DOCTYPE html>
<html lang="pl">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>PDF</title>
</head>
<body>
    <table>
        <tbody>
            <tr>
                <td>
                    <h4>List 1:</h4>
                    <ol>
                        @foreach ($listArray_1 as $inv)
                            <li>{{ $inv->firstname }} {{ $inv->middlename }} {{ $inv->lastname }}</li>
                        @endforeach
                    </ol>
                </td>

                <td>
                    <h4>List 2:</h4>
                    <ol>
                        @foreach ($listArray_2 as $inv)
                            <li>{{ $inv->firstname }} {{ $inv->middlename }} {{ $inv->lastname }}</li>
                        @endforeach
                    </ol>
                </td>

                <td>
                    <h4>List 3:</h4>
                    <ol>
                        @foreach ($listArray_3 as $inv)
                            <li>{{ $inv->firstname }} {{ $inv->middlename }} {{ $inv->lastname }}</li>
                        @endforeach
                    </ol>
                </td>

                <td>
                    <h4>List 4:</h4>
                    <ol>
                        @foreach ($listArray_4 as $inv)
                            <li>{{ $inv->firstname }} {{ $inv->middlename }} {{ $inv->lastname }}</li>
                        @endforeach
                    </ol>
                </td>
            </tr>
        </tbody>
    </table>
</body>
</html>

But if some <td> is larger than page height, it's making 2 firsts pages blank and on third page rendering cutted content (cutted to end of page). 但是,如果某些<td>大于页面高度,则会使2个第一页空白,并在第三页上呈现剪切的内容(剪切到页面末尾)。
Where is problem? 问题在哪里? In CSS or DOM PDF? 在CSS或DOM PDF中? (I cannot use wkhtmltopdf :/ ) (我不能使用wkhtmltopdf:/)

Possible solution using another library: I use mPDF for this task. 使用其他库的可能解决方案:我将mPDF用于此任务。 I can imagine it is a very hard process internally in mPDF, but managed to get a good pdf, using multiple tables that might or might not span multiple pages. 我可以想象这在mPDF内部是一个非常艰巨的过程,但是却成功地使用了多个可能跨越多个页面的表来获得一个良好的pdf。 All goes well. 一切顺利。

$mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/tmp']);
$mpdf->shrink_tables_to_fit = false;
$mpdf->WriteHTML( <<<HTML
<style>    
table
{
     page-break-inside: avoid;
}
</style>
<table>.... LONG table</table>
<table>.... another table</table>
<table>.... LONG table</table>
HTML
);

` `

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM