PhpWord,得到的总页数减去2

时间:2018-11-18 03:29:21

标签: php phpword

我的PhpWord版本使用的是“ v0.14”,我想将第三页页脚的格式更改为“ 1/1”而不是“ 1/3”,即省略前两页。我该如何修改总页数?期待您的重播! 这是我的部分源代码:

require_once 'phpword/autoload.php';

$PHPWord = new \PhpOffice\PhpWord\PhpWord();
$section = $PHPWord->addSection();

$fontStyle1= array('name' => 'mysh', 'size' => 48);
$paraStyle1= array('align'=>'center','spacing'=>10);

$fontStyle2= array('name' => 'mysh', 'size' => 18);
$paraStyle2= array('align'=>'center','spacing'=>5);

$section->addTextBreak(18);
$section->addText("COVER",$fontStyle1,$paraStyle1);
$section->addPageBreak();

$section->addText("Introduction",$fontStyle2,$paraStyle2);


$section2 = $PHPWord->addSection(array('pageNumberingStart' => 1));
$footer = $section2->addFooter();
$footer->addPreserveText("{PAGE}/{NUMPAGES}",array('color'=>'ff0000','size'=>24),array('alignment' =>'center'));//\PhpOffice\PhpWord\SimpleType\Jc::CENTER
$section2->addPageBreak();
$section2->addPageBreak();

$PHPWord->save('C:/Users/wsco/Desktop/test.docx');

这是我的输出: enter image description here

0 个答案:

没有答案