代码之家  ›  专栏  ›  技术社区  ›  Pranav Mandlik

生成PDF时第一行打印不正确

  •  1
  • Pranav Mandlik  · 技术社区  · 6 年前

    我有以下html代码在我的文件生成PDF,但结果PDF是不能正确生成。

    <table border="1"  class="table table-striped">
    
        <thead>
            <th>Sr No.</th>
            <th>Particulars </th>
            <th>Qty </th>
            <th>rate </th>
            <th>Amount </th>
        </thead>
    
        <tbody>
            <br><br>
            @foreach($data as $row)
    
            <tr>
                <td>{{ $row['temp_invoice_id']  }}</td>
                <td>{{ $row['tyre_brand']." ".$row['tyre_model']  }}</td>
                <td>{{ $row['quantity']  }}</td>
                <td>{{ $row['rate']  }}</td>
                <td>{{ $row['total']  }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
    

    但是当生成PDF时,它会显示出类似这样的内容,我不知道为什么它不能生成正确的PDF。任何人都可以解决这个问题,或者我们必须单独应用 css

    enter image description here

    2 回复  |  直到 6 年前
        1
  •  1
  •   ram pa    6 年前

    在ad-use-tr标签内,它工作正常。

         <thead>
            <th>Sr No.</th>
            <th>Particulars </th>
            <th>Qty </th>
            <th>rate </th>
            <th>Amount </th>
        </thead>
    

    像这样使用,

            <thead>
              <tr>
                <th>Sr No.</th>
                <th>Particulars </th>
                <th>Qty </th>
                <th>rate </th>
                <th>Amount </th>
              </tr>
            </thead>
    
        2
  •  0
  •   Lithilion    6 年前

    拆下 <br><br> 在你的 <tbody> 它们是无效的,所以浏览器可能会忽略它们,但是PDF生成器(我不知道您使用哪一个)可能不会。
    同时放置 <th> 在一排里面( <tr>