为了账号安全,请及时绑定邮箱和手机立即绑定

在 fPDF/tfPDF 中创建编号页组

在 fPDF/tfPDF 中创建编号页组

PHP
互换的青春 2022-01-08 14:51:28
我正在使用这个插件,它可以帮助我创建不同的页面组。我有两个主要问题。首先我正在使用PHP 7.3并且我不想使用旧版本,PHP因为我有其他代码正在使用PHP 7.3. 第一个问题出现在第 33 行文件 - pagegroup.php:$n = sizeof($this->PageGroups) + 1;我收到错误sizeof():参数必须是数组或者实现了Countable的对象我试图用这些代码改变这一行:if (empty($this->PageGroups)) {    $n = 1;} else {    $n = count($this->PageGroups)+1;}有人可以确认我这工作正常吗,因为我的第二个问题是当我输入这段代码时:require 'lib/pagegroup.php';class MYPDF extends PDF_PageGroup {    function Header() {        $this->Cell(0, 6, 'Page '.$this->GroupPageNo().'/'.$this->PageGroupAlias(), 0, 0, 'C');    }    for ($i = 0; $i < 2; $i++) {    $pdf->StartPageGroup();    $pdf->AddPage();    // some other code ...    }}GroupPageNo工作得很好,但PageGroupAlias正在返回{nb1},对于组页面 2 它正在返回{nb2}。所以我最终得到了1/{nb1}and1/{nb2}并且最终的结果应该是1/1and1/1例如。
查看完整描述

1 回答

?
FFIVE

TA贡献1797条经验 获得超6个赞

我设法使它在 PHP 7.3 下工作。这是我在方法_beginpage 中的工作代码,我更改了这一行:


$n = sizeof($this->PageGroups)+1;

用这些线:


if (empty($this->PageGroups)) {

    $n = 1;

} else {

    $n = count($this->PageGroups) + 1;

}

其他最重要的事情是它必须将字体系列设置为Arial 以其他方式它不起作用并且它正在显示{nb2}。所以应该是这样的。


require 'lib/pagegroup.php';


class MYPDF extends PDF_PageGroup {

    function Header() {

        $this->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true);

        $this->SetFont('Arial', '', 10);

        $this->Cell(0, 6, 'Page '.$this->GroupPageNo().'/'.$this->PageGroupAlias(), 0, 0, 'C');

        // change the font to the one you want to use in my case DajaVu

        $this->SetFont('DejaVuSans', '', 16);

    }


    for ($i = 0; $i < 2; $i++) {


    $pdf->StartPageGroup();

    $pdf->AddPage();


    // some other code ...

    }

}


查看完整回答
反对 回复 2022-01-08
  • 1 回答
  • 0 关注
  • 141 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信