PHPWord how to add text break / new line while in a text run

user2579723 picture user2579723 · Jul 17, 2013 · Viewed 31.5k times · Source

How can I add a text break or go to the next line/row while in a text run? I tried to just do $section->addTextBreak(2); while in the text run but it just added the breaks to the section after the text run. I also tried $textrun->addTextBreak(2); but it gave me a fatal error. Any responses would be greatly appreciated.

Answer

gaelle3182 picture gaelle3182 · Nov 8, 2016

The question was asked 3 years ago but I have the same problem and I found a solution. Maybe this can help new users of PHPWord.

To add a crlf in Word document the tag can help :

$section->addText('Some text <w:br/> another text in the line ');

I found the solution here : http://jeroen.is/phpword-line-breaks/