php 网格系统未按预期与DomPdf一起工作

twh00eeo  于 2023-08-02  发布在  PHP
关注(0)|答案(1)|浏览(106)

我正在使用DomPdf从刀片文件生成PDF,该文件在同一行中有两个表。当我将刀片显示为网页时,它会按预期显示,但当我将其转换为PDF时,每个表都会显示在单行中。
我想要的是:

的数据
我得到了什么:



这是我的两个表的刀片代码:

<div class="row">
    <div class="col-xl">
        <div class="table-responsive">
            <table class="table table-bordered table-sm" >
                <tbody>
                    <tr>
                        <th scope="row" style="width: 15%"><strong>Assigment No.:</strong></th>
                        <td>
                            FICT-ASSIGN-202207034356
                        </td>

                    </tr>
                    <tr>
                        <th scope="row" style="width: 15%"><strong>Period No.:</strong></th>
                        <td>
                            1
                        </td>
                    </tr>
                    <tr>
                        <th scope="row" style="width: 15%"><strong>Number of Pages:</strong></th>
                        <td>
                            1
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

    </div>
    <div class="col-xl">
        <div class="table-responsive" >
            <table class="table table-bordered table-sm">
                <tbody>
                    <tr>
                        <th scope="row"><strong>Client:</strong></th>
                        <td>
                            First International for Consults & Training
                        </td>
                    </tr>
                    <tr>
                        <th scope="row"><strong>Address:</strong></th>
                        <td>
                            Office #1, Floor #1, Building #11, Ibn Seena St #10, Al Muntazah #1
                        </td>
                    </tr>
                    <tr>
                        <th scope="row"><strong>City:</strong></th>
                        <td>
                            Doha
                        </td>
                    </tr>
                    <tr>
                        <th scope="row"><strong>Phone No.:</strong></th>
                        <td>
                            (+974) 4444 4444
                        </td>
                    </tr>
                    <tr>
                        <th scope="row"><strong>Email:</strong></th>
                        <td>
                            info@example.com
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

字符串
我用的是col-col-xscol-xl,都不好用。
这是我如何生成PDF的:

public function getPdf()
{
    $t = $this->generateAssignPDF();
    return $t->stream();
}

private function generateAssignPDF()
{

    $pdf = app('dompdf.wrapper');
    $pdf = $pdf->loadView('pdf_temps.assign_card')
    ->setPaper('a4', 'portrait');
    return $pdf;
}


我正在使用:
Laravel v9
PHP v8.1.5
Bootstrap v4.1.3
DomPdf v2

1szpjjfi

1szpjjfi1#

最后,我突然想到了一个主意,将两个表包含在一个表中,并按预期工作
下面是我的代码:

<table class="table table-borderless" >
    <tbody>
        <tr>
            <td style="width: 50%; padding:0%;">
                <div class="table-responsive">
                    <table class="table table-borderless table-sm" >
                        <tbody>
                            <tr>
                                <th scope="row" style="width: 30%"><strong>Assigment No.:</strong></th>
                                <td>
                                    FICT-ASSIGN-202207034356
                                </td>
    
                            </tr>
                            <tr>
                                <th scope="row"><strong>Period No.:</strong></th>
                                <td>
                                    1
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><strong>Number of Pages:</strong></th>
                                <td>
                                    1
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div> 
            </td>
            <td style="width: 50%; padding:0%;">
                <div class="table-responsive" >
                    <table class="table table-borderless table-sm">
                        <tbody>
                            <tr>
                                <th scope="row" style="width: 20%"><strong>Client:</strong></th>
                                <td>
                                    First International for Consults & Training
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><strong>Address:</strong></th>
                                <td>
                                    Office #1, Floor #1, Building #11, Ibn Seena St #10, Al Muntazah #1
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><strong>City:</strong></th>
                                <td>
                                    Doha
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><strong>Phone No.:</strong></th>
                                <td>
                                    (+974) 4444 4444
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><strong>Email:</strong></th>
                                <td>
                                    info@example.com
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </td>
        </tr>
    </tbody>
</table>

字符串

相关问题