2016-03-03 38 views
0

我很難讓spaceAfterspaceBeforePHPWord中工作。PhpWord spaceAfter不工作

如果我請勿包括在段落樣式spaceAfterspaceBefore,那麼部分將前後有一定的空間。

如果我DO包括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" 
    ) 
); 

回答

2

你應該將其添加爲 「TWIP」,像這樣:

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

Converter類也有方法inchToTwipcmToTwip。上TWIP

更多信息:

基部長度單元打開Office XML是TWIP。 Twip意思是「英寸點的三分之一」,即1緹= 1/1440英寸。

+1

謝謝。沒有在文檔中看到這一點。感謝幫助。 – James

+0

在文檔中沒有提及任何地方。謝謝。 –