PHPWord页脚位置

问题描述 投票:1回答:1

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

我在文本方面完全按照要求设置了一个页脚。

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

但是,我想要实现的目标是:

降低页脚的高度或设置页面底部的距离。

Space I'd like to remove

在Word365中有一个名为“Footer from bottom”的选项,在旧版本的Word中也有类似的选项。

Option in Word365

我已经尝试调整页边距但这些看起来与页脚(和页眉)的位置是分开的。

position footer margins phpword phpoffice
1个回答
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);
© www.soinside.com 2019 - 2024. All rights reserved.