Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpword addText() align justify

Tags:

phpword

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');
like image 981
Руккола Avatar asked Jul 14 '15 07:07

Руккола


1 Answers

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');
like image 136
Nue Avatar answered Oct 11 '22 12:10

Nue