【问题标题】:Dompdf footer not set..?Dompdf 页脚未设置..?
【发布时间】:2017-01-31 01:59:19
【问题描述】:

这里我使用 dompdf 生成带有一些页眉、正文、页脚的 pdf。 但是当我尝试添加页脚时,它没有附加。

它总是带有正文代码, 我想在底部设置页脚。

谁能弄清楚我在下面的代码哪里错了?

代码:

    global $_dompdf_show_warnings;
    global $_dompdf_debug;
    global $_DOMPDF_DEBUG_TYPES;
    global $_dompdf_warnings;
    $_dompdf_show_warnings = FALSE;

    require_once(realpath(APPPATH."third_party/dompdf")."/dompdf_config.inc.php"); 
    spl_autoload_register('DOMPDF_autoload');

    $dompdf = new DOMPDF();
    $dompdf->set_paper("letter", "portrait");

    $html = '<html>
                <head>
                    <title>
                    </title>
                    </head>

`enter code here`                  <body style="margin:0; background-color:#ff9900; color:#ffffff;">
                        <div>
                            <div style="margin:15px;">
                                <div>
                                    <span style="font-size:25px; font-weight:600;">
                                        Hi, John
                                    </span>
                                </div>
                                <div>
                                    <span>
                                        Your account statement is here.
                                    </span>
                                </div>

                                <div style="margin-top:15px; border: 2px solid;border-radius:5px; padding:10px; position:absolute; diplay:block;">
                                    <div style="float:left;">left</div>
                                    <div style="float:right;">right</div>
                                </div>
                            </div>
                        </div>
                        <div style="background-color:#ffffff; color:#ff9900; position:fixed; bottom:0;width:100%;padding:10px;">
                            <div>
                                <span>
                                    <b><i>This is a system generated statement.</i></b>
                                </span>
                            </div>
                            <div>
                                <span>
                                   <b><i> If you have any queries, email support@xyz.com.</i></b>
                                </span>
                            </div>
                        </div>
                    </body>
                </html>';


        $dompdf->load_html($html);
        $dompdf->render();

        $dompdf->stream("dompdf_out.pdf", array("Attachment" => false));

【问题讨论】:

  • 您的代码示例中有一个随机的“enter code here”文本?

标签: php footer dompdf


【解决方案1】:

在 dompdf(直到并包括 0.7.0 版)中,元素(一般而言)从它们首次出现的页面开始呈现。因此,您需要将任何固定内容(例如,设置为固定的页眉/页脚)放在文档顶部。

参考:https://github.com/dompdf/dompdf/issues/688#issuecomment-21818867

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2011-06-27
    • 2012-03-07
    • 2016-06-16
    • 2013-11-15
    • 1970-01-01
    • 1970-01-01
    • 2013-02-16
    • 2012-02-26
    相关资源
    最近更新 更多