我使用PHPWord来使用模板,但当我以HTML格式保存文件时,我只看到它的正文,而看不到页眉或页脚。所以我想让这些部分插入HTML部分
$Content = IOFactory::load($saveDocPath);
$Writer = IOFactory::createWriter($Content,'HTML');
$Writer->save($savePath);
如果我使用dd((,我可以看到docx文件的页眉和页脚
#phpWord: PhpOfficePhpWordPhpWord {#1299 ▼
-sections: array:1 [▼
0 => PhpOfficePhpWordElementSection {#1493 ▼
#container: "Section"
-style: PhpOfficePhpWordStyleSection {#1494 ▶}
-headers: array:1 [▶]
-footers: array:1 [▶]
-footnoteProperties: null
#elements: array:25 [▶]
你不能。引用了其中一位贡献者的话:
页眉&页脚仅适用于打印页面,而HTML则不适用。
https://github.com/PHPOffice/PHPWord/issues/1105#issuecomment-317132143