PhpWord空间不工作后


PhpWord spaceAfter Not Working

我无法让spaceAfterspaceBeforePHPWord工作。

如果我不在段落样式中包含spaceAfterspaceBefore,则该部分前后将有一些空间。

如果我确实包含spaceAfterspaceBefore那么无论我为间距输入什么,空格都会变为 0。

我可以让其他段落样式同时工作,例如lineHeight工作正常。

例:

$section->addText(
    "Some Text",
    array(
        "italic" => true
    ),
    array(
        "lineHeight" => 2.0,  //Works fine
        //I don't put all of these at once
        //I just want to show some of the different parameters I've used
        //And I've done the same with spaceAfter
        "spaceBefore" => 1.0,
        "spaceBefore" => "1.0",
        "spaceBefore" => .5,
        "spaceBefore" => ".5"
    )
);

您应该将其添加为"twip",如下所示:

'spaceBefore' => 'PhpOffice'PhpWord'Shared'Converter::pointToTwip(6))

Converter类也有方法inchToTwipcmToTwip

关于缇的更多信息:

Open Office XML 中的基本长度单位是 twip。Twip 的意思是"二十英寸点",即 1 缇 = 1/1440 英寸。