【问题标题】:dompdf page breakes not workingdompdf分页符不起作用
【发布时间】:2015-12-09 02:07:06
【问题描述】:

here is sample image

    <!DOCTYPE html>
<html class="bg-black">
<head>
    <meta charset="UTF-8">
    <title><?php if(isset($title)) echo $title.' | '; ?>  Sales agent management software (SAMS) </title>

    <style>
        body{
            font-size: 9px;
            margin: 20px;
        }
        th,td,p,div,table,h3{margin:0;padding:0}

        @page { margin: 20px; }

        .header{
            border-bottom: 1px solid #dddddd;
            text-align: center;
            position: fixed; top: 0;
        }
        .footer { position: fixed; bottom: 0px; text-align: center }
        .pagenum:before { content: counter(page); }

    </style>
</head>

<body>

<div class="header">
    <h2><?php echo get_option('company_name'); ?> Catalog</h2>
</div>
<br /><br />

<div class="footer">Page: <span class="pagenum"></span>, creation time : <?php echo date('l jS \of F Y h:i:s A') ?>, create by: <?php echo user_full_name(singleDbTableRow(loggedInUserData()['user_id'])); ?></div>

<br />
<div class="box-body">

    <?php
    $usd = get_option('lkr_per_usd', 134);
    ?>


    <?php
    $result = array_chunk($products->result_array(), 3);

    foreach($result as $products){  ?>
        <table style="width:100% style="page-break-after:always;"   >

        <tr>
        <?php 
        foreach($products as $productArray){
            $product = (object) $productArray;
            echo '<td>';
        ?>

        <div style="width: 100%; height: 210px;  border: 1px solid #dddddd; margin: 10px; padding: 5px;">
                <div class="box-header">
                    <p class="box-title"><FONT SIZE=12><?php echo $product->product_name; ?></FONT></p>
                </div>
                <div style="height: 80px; text-align: center;">
                    <?php echo '<img src="'.'uploads/'. $product->photo.'" class="img-responsive" style="height:80px !important; width: 150px !important"  />'; ?>
                </div>

                <div style="clear: both"></div>
                <table class="table table-responsive">
                    <tr>
                        <th><FONT SIZE=12>ID</FONT></th>
                        <td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td>
                    </tr>
                    <tr>
                        <th><FONT SIZE=12>LKR</FONT></th>
                        <td><FONT SIZE=14><?php $lkr = get_selling_price($product);
                            echo  number_format(round($lkr, get_option('round_precision')) ); ?></FONT>
                        </td>
                    </tr>
                    <tr>
                        <th> <FONT SIZE=12>US $</FONT></th>
                        <td><FONT SIZE=14><?php echo number_format(round(lkr_to_usd($lkr), get_option('round_precision')) ); ?></FONT></td>
                    </tr>
                </table>

        </div>

            </td>
        <?php } ?>

    </tr>

    <?php } ?>

    </table>
</div><!-- /.box-body -->


</body>

</body>
</html>

当我尝试生成 pdf 时,它总是这样。我在上面添加了我的生成 pdf 代码。 第二页不像第一页那样出现..我搜索并找到了其他人的问题的其他 dompdf 解决方案。但我的问题出在第 2 页,它不是第 1 页。

【问题讨论】:

  • 既然问题不在于您的 PHP 代码,您能否提供一个传递给 dompdf 的 HTML 示例?

标签: php html css dompdf


【解决方案1】:

dompdf 方面存在一些错误行为。出于某种原因,使用width: 100% 对包含您的产品信息的 DIV 进行样式设置会在分页表格行时破坏布局。如果您从 DIV 中删除该样式,则文档应按预期呈现。默认的 DIV 布局是全宽的,因此您可以将 DIV 上的宽度样式留出

【讨论】:

    猜你喜欢
    • 2014-04-04
    • 2011-06-27
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-01
    • 1970-01-01
    相关资源
    最近更新 更多