带有顶部和底部边框的自定义 PHP tcpdf 页脚 [英] custom PHP tcpdf footer with top and bottom border

查看:22
本文介绍了带有顶部和底部边框的自定义 PHP tcpdf 页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次使用 TCPDF,很棒的库.

First time use TCPDF, great library.

我尝试创建一个自定义页脚,但是我想创建一个自定义页脚,其中包含带有顶部和底部边框的 div 中的页码和日期!那么有什么帮助吗?

I try to create a custom footer, however i want to create a custom footer that include the page number and date inside a div with top and bottom border! So any help?

非常感谢

推荐答案

Karel 在这方面是对的.

Karel is right on this.

但是,如果 Footer() 函数给您的动态带来麻烦,您可以忽略它.在我看来,您希望在页脚中有一个 div.

you could however ignore the Footer() function if it's getting you in trouble with the dynamic of it. seems to me that you would like to have a div in your footer.

要做到这一点,你必须先去掉默认的页脚:

to do this you have to get rid of the default footer first:

$this->setPrintFooter(false);

然后创建您自己的页脚函数.

and then create your own footer function.

public function _footer($input) {
    $html = $input;

    $this->setY(-15); // so the footer is an actual footer.

    $this->writeHTMLCell(
        $width = 0, // width of the cell, not the input
        $height = 0, // height of the cell..
        $x,
        $y,
        $html = '', // your input.
        $border = 0,
        $ln = 0,
        $fill = false,
        $reseth = true,
        $align = '',
        $autopadding = true 
    );
}

上述函数的值是默认值.所以你可能想要编辑它们.

the values of the above function are the defaults. so you may want to edit them.

这样的调用:

$div = '<div id="footer">wow this is a nice footer</div>'>
$pdf->_footer($div);

您使用 $div 输入创建 HTML 单元格.

you create your HTML cell with the $div input.

要获取页码和类似内容,只需查看 TCPDF 文档页面:http://www.tcpdf.org/doc/code/classTCPD.html

to get the page numbers and stuff like that just checkout the TCPDF documentation page: http://www.tcpdf.org/doc/code/classTCPDF.html

希望这有助于理解它.这只是一个从头开始的例子.随心所欲地编辑它并尝试一些东西来让您的 PDF 文档运行.

hope this helps a little bit to understand it. this is just an example from scratch. edit it as you like and try out some stuff to get your PDF document going.

这篇关于带有顶部和底部边框的自定义 PHP tcpdf 页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆