Php 在fPDF/tfPDF中创建编号页面组
我正在使用插件,它可以帮助我创建不同的页面组。我有两个主要问题。首先,我使用的是Php 在fPDF/tfPDF中创建编号页面组,php,fpdf,Php,Fpdf,我正在使用插件,它可以帮助我创建不同的页面组。我有两个主要问题。首先,我使用的是PHP7.3,我不想使用较旧版本的PHP7.3,因为我还有其他代码在使用PHP7.3。第一个问题出现在第33行文件-pagegroup.php: $n = sizeof($this->PageGroups) + 1; require 'lib/pagegroup.php'; class MYPDF extends PDF_PageGroup { function Header() {
PHP7.3
,我不想使用较旧版本的PHP7.3
,因为我还有其他代码在使用PHP7.3
。第一个问题出现在第33行文件-pagegroup.php:
$n = sizeof($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 ...
}
}
我犯了一个错误
sizeof():参数必须是实现可计数的
我试图用以下代码更改这一行:
if (empty($this->PageGroups)) {
$n = 1;
} else {
$n = count($this->PageGroups)+1;
}
有人能确认我这工作正常吗,因为我的第二个问题是当我输入代码时:
$n = sizeof($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 ...
}
}
需要'lib/pagegroup.php';
类MYPDF扩展了PDF_页面组{
函数头(){
$this->Cell(0,6,'Page'.$this->GroupPageNo()./'.$this->PageGroupAlias(),0,0,'C');
}
对于($i=0;$i<2;$i++){
$pdf->StartPageGroup();
$pdf->AddPage();
//其他一些代码。。。
}
}
GroupPageNo工作正常,但是PageGroupAlias正在返回
{nb1}
,对于group page 2,它正在返回{nb2}
。因此,我最终得到了1/{nb1}
和1/{nb2}
,最后的结果应该是1/1
和1/1
。我设法使它在PHP7.3下工作。这是我在方法中的工作代码\u 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 ...
}
}
需要'lib/pagegroup.php';
类MYPDF扩展了PDF_页面组{
函数头(){
$this->AddFont('DejaVuSans','DejaVuSans.ttf',true);
$this->SetFont('Arial','',10);
$this->Cell(0,6,'Page'.$this->GroupPageNo()./'.$this->PageGroupAlias(),0,0,'C');
//将字体更改为您希望在我的案例DajaVu中使用的字体
$this->SetFont('DejaVuSans','',16);
}
对于($i=0;$i<2;$i++){
$pdf->StartPageGroup();
$pdf->AddPage();
//其他一些代码。。。
}
}
我设法让它在PHP7.3下工作。这是我在方法中的工作代码\u 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 ...
}
}
需要'lib/pagegroup.php';
类MYPDF扩展了PDF_页面组{
函数头(){
$this->AddFont('DejaVuSans','DejaVuSans.ttf',true);
$this->SetFont('Arial','',10);
$this->Cell(0,6,'Page'.$this->GroupPageNo()./'.$this->PageGroupAlias(),0,0,'C');
//将字体更改为您希望在我的案例DajaVu中使用的字体
$this->SetFont('DejaVuSans','',16);
}
对于($i=0;$i<2;$i++){
$pdf->StartPageGroup();
$pdf->AddPage();
//其他一些代码。。。
}
}