phpword addText() align justify

Руккола picture Руккола · Jul 14, 2015 · Viewed 17.2k times · Source

When I use addText() it works fine with align=center, left or right, but when I try use align=justify script works without problems, but when I try to open .docx file it gives me error and file is not openning.

It would be appreciated if someone knows solution.

$text = "some text";
$PHPWord->addFontStyle('r2Style', array('bold'=>false, 'italic'=>false, 'size'=>12));
$PHPWord->addParagraphStyle('p2Style', array('align'=>'center', 'spaceAfter'=>100));
$section->addText($text, 'r2Style', 'p2Style');

Answer

Nue picture Nue · May 17, 2016

try change 'align'=>'left' to 'align'=>'both'

$text = "some text";
$PHPWord->addFontStyle('r2Style', array('bold'=>false, 'italic'=>false, 'size'=>12));
$PHPWord->addParagraphStyle('p2Style', array('align'=>'both', 'spaceAfter'=>100));
$section->addText($text, 'r2Style', 'p2Style');