PHPWord页脚位置

时间:2019-03-07 14:10:40

标签: position footer margins phpword phpoffice

有人知道是否可以使用PHPWord重新定位(或设置页脚的高度)?

我的页脚完全符合文字要求。

$footer = $section->addFooter();
$textrun = $footer->addTextRun();
$textrun->addText('My Footer Text');

但是,我想要实现的是:

减小页脚的高度或设置距页面底部的距离。

Space I'd like to remove

Word365中有一个名为“自下而上的脚”的选项,在较旧版本的Word中也有类似的选项。

Option in Word365

我尝试过调整页边距,但这些页边距似乎与页脚(和页眉)位置分开。

1 个答案:

答案 0 :(得分:0)

我通过查看GitHub存储库设法找到了解决方案。

此提交提供了一种解决方案:Added support for page header & page footer height

在创建包含页眉和页脚的部分时,可以传递属性“ headerHeight”和“ footerHeight”。

// Adding an empty Section to the document...
$section = $this->_phpWord->addSection(array(
                        'headerHeight' => 300,
                        'footerHeight' => 50)
                    );

$footer = $section->addFooter();
$textrun = $footer->addTextRun();
$textrun->addText('My Footer Text');

创建节后,还有一些公共方法可以设置这些值,它们是:setFooterHeight()和setHeaderHeight()。

$section->setHeaderHeight(300);
$section->setFooterHeight(50);
相关问题