【问题标题】:HTMl Table's border not showing on Php PDFHTMl 表格的边框未显示在 Php PDF 上
【发布时间】:2017-01-30 21:20:36
【问题描述】:

当我将我的 pdf 打印到屏幕上时,为什么我的表格的边框没有出现?

我正在使用 mPDF 库。

我在 html 中创建表格,但由于某种原因它没有显示。

我已经尝试过使用内联 CSS,但它对我来说不起作用。

<?php
    require_once 'MPDF57\MPDF57\mpdf.php';

    class TablePDF {
        public function printPDF() {
            $mpdf = new mPDF();
            $border = 2 ;
            $mpdf->SetHeader("Tabela");
            $mpdf->SetFooter("Tabela");
            $htmlpdf= "
                <html>
                    <head>
                        <link type='text/css' rel=' rel='heet' href=' href='tstrap.min.css'>
                        <link type='text/css' rel='stylesheet' href='css/estilo.css'>
                        <style type='.text/css.'>
                            <title>Table</title>
                        </style>
                        .td{
                            style='border: 1px solid';
                          }
                    </head>
                    <body>
                        <table class='tabela' border=".$border." style='border:10px solid;'>
                            <tr style='border:10px solid black'>
                                <th width='150' style='border:10px solid black; '>GE</th>
                                <td width='200' style='border:10px solid black; '>0</td>
                                <td width='200' style='border:10px solid black; '><strong>Nome Curto</strong></td>
                                <td width='200' style='border:10px solid black;  '>0</td>
                            </tr>
                        </table>

                        <table class='tabela' border=".$border." style='border:10px solid black'>
                            <tr>
                                <th width='150'>Valor</th>
                                <td width='200'>0</td>
                                <td width='200'><strong>FG</strong></td>
                                <td width='200'>0</td>
                            </tr>
                        </table>

                        <table class='tabela' border=".$border." style='border:10px solid black'>
                            <tr>
                                <th width='150'> Jugular </th>
                                <td width='117'>0</td>
                                <td width='117'>0</td>
                                <td width='117'>0</td>
                                <td width='118'>0</td>
                                <td width='119'>0</td>
                            </tr>
                        </table>

                        <table class='tabela' border=".$border." style='border:10px solid black'>
                            <tr>
                                <th width='150'>EXP3D</th>
                                <td width='200'>0</td>
                                <td width='200'>0</td>
                                <td width='200'>0</td>
                            </tr>
                        </table>

                        <table class='tabela' border=".$border." style='border:10px solid black'>
                            <tr>
                                <th width='150'>EXP28D</th>
                                <td width='200'>0</td>
                                <td width='200'>0</td>
                                <td width='200'>0</td>
                            </tr>
                        </table>

                        <table class='tabela' border=".$border." style='border:10px solid black'>
                            <tr>
                                <th width='150'>Carotida</th>
                                <td width='303'>0</td>
                                <td width='303'>0</td>
                            </tr>
                        </table>

                    </body>
                </html>";
            $mpdf -> useOnlyCoreFonts = true;
            $mpdf->WriteHTML($htmlpdf);
            $mpdf->Output();
        }
    }
?>

然后我就用这个函数来打印pdf:

<?php
    require_once 'TablePDF.php';
    $var = new TablePDF();
    $var->printPDF();
?>

编辑:问题已解决,我刚开始删除 TABLE 标记行中的表类,因为由于某种原因它没有将其识别为类。

非常感谢大家。

【问题讨论】:

    标签: php html css pdf


    【解决方案1】:
    td {
        border: 1px solid;
    }
    

    您不必每次需要在页面中使用 td 时都创建样式,只需调用样式即可。

    【讨论】:

    • 这看起来不像是有效的 CSS。我错过了什么吗?
    • 据我所知,在样式声明中使用style: 是非法的。
    猜你喜欢
    • 1970-01-01
    • 2014-06-08
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 2020-05-24
    • 1970-01-01
    • 1970-01-01
    • 2014-10-16
    相关资源
    最近更新 更多