简体   繁体   English

未设置Dompdf页脚。

[英]Dompdf footer not set..?

Here I am using the dompdf for generating pdf with some header,body,footer. 在这里,我使用dompdf生成带有某些页眉,正文,页脚的pdf。 But when i try to add the footer ,it's not attaching. 但是当我尝试添加页脚时,它没有附加。

It always come with the body code, I want to set a footer at bottom. 它总是与正文代码一起提供,我想在底部设置页脚。

Can anyone figure-out that where i am wrong with the below code ? 任何人都可以找出下面的代码我错了吗?

Code : 代码:

    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));

In dompdf (up to and including version 0.7.0) elements are (generally speaking) rendered starting with the page on which they first appear. 在dompdf(0.7.0版及以下版本)中,(通常来说)元素是从首次出现的页面开始渲染的。 Because of this you'll want to put any fixed content (ex. header/footer set to fixed) at the top of your document. 因此,您需要将所有固定内容(例如,将页眉/页脚设置为固定)放在文档顶部。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM