I'm using PHPWord and would like to set the spaceAfter paragraph style to 0 for every paragraph. Unfortunately, I'm unaware of how to do this globally. You can set the font size / name globally by doing this:
$phpWord->setDefaultFontName('Times New Roman');
$phpWord->setDefaultFontSize(12);
But how might I set the spaceAfter default paragraph style?
Per http://phpword.readthedocs.org/en/latest/elements.html#paragraph-style I can also set it every time I call addText()
(by setting the third parameter) but that could get old, fast.
Setting it globally would be the ideal approach.
I'm using Beta 0.6.3.
Any ideas?
The Beta 0.6.3 version (in CodePlex) is an old inactive project - there is a new active version (that is based on that CodePlex project) in GitHub that you can find here PhpWord: GitHub
And with the new project version (no idea if this applicable in the old 0.6.3 as well), you can set the default paragraph style like this (copied from Sample_08_ParagraphPagination.php):
$phpWord->setDefaultParagraphStyle(
array(
'align' => 'both',
'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12),
'spacing' => 120,
)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With