PhpWord 空间不工作后

PhpWord spaceAfter Not Working

我无法让 spaceAfterspaceBeforePHPWord 中工作。

如果我不要在段落样式中包含spaceAfterspaceBefore,那么该部分前后会有一些space .

如果我 DO 包括 spaceAfterspaceBefore 然后 space 变为 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 class 也有方法 inchToTwipcmToTwip.

有关缇的更多信息:

The base length unit in Open Office XML is twip. Twip means “TWentieth of an Inch Point”, i.e. 1 twip = 1/1440 inch.