PHPWord addTOC 不显示页码

问题描述 投票:0回答:2

我正在使用 https://github.com/PHPOffice/PHPWord 生成Word文档。 函数 addTOC 生成带有标题的页面索引,但由于某种原因,页码不显示。

// add table of contents
$section->addTOC();

结果:

Table of contents

如果我在标题所在的页面上回显页码,它们就会显示得很好。 但它们不会显示在目录中。 我检查了一下,确认文字不是白色的。

phpword phpoffice
2个回答
0
投票

从示例目录中的 PHPWord 示例(https://github.com/PHPOffice/PHPWord/blob/develop/samples/Sample_17_TitleTOC.php),我想说这是不可能的:

echo date('H:i:s'), '注意:请手动刷新目录。', EOL;

我还尝试在文档末尾、标题声明之后添加目录(当我们已经知道页码时)。但没有成功。

编辑:似乎是一个错误:https://github.com/PHPOffice/PHPWord/issues/707


0
投票

使用此代码更新字段

$phpWord->getSettings()->setUpdateFields(true);
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.