Reputation: 1572
I'm having trouble getting spaceAfter
and spaceBefore
to work in PHPWord
.
If I DO NOT include spaceAfter
or spaceBefore
in the paragraph styles, then the section will have some space before and after.
If I DO include spaceAfter
or spaceBefore
then the space goes to 0, no matter what I put in for the spacing.
I can get other paragraph styles to work at the same time, lineHeight
for example works fine.
example:
$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"
)
);
Upvotes: 1
Views: 3698
Reputation: 2823
You should add it as "twip", like this:
'spaceBefore' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(6))
Converter
class also has methods inchToTwip
and cmToTwip
.
More info on twip:
The base length unit in Open Office XML is twip. Twip means “TWentieth of an Inch Point”, i.e. 1 twip = 1/1440 inch.
Upvotes: 4