Forum


Replies: 2   Views: 7408
How to add line break between two words
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Sven May  · 21-02-2015 - 17:03

Hello! I have a table with columns. In one cell I have to display two words with line breaks: Example: First word Second word How I try: $valueFragment = new WordFragment($docx); $text = array(); $text[] = array('text'=>'optional','bold'=>true,'caps'=>true,'color'=>'FFFFFF','columnBreak'=>'after'); $text[] = array('text'=>"\n"); $text[] = array_merge(array('text'=>'Word fragment'), $properties); $valueFragment->addText($text); $valueCell = array('value'=>$valueFragment, 'width' => 3000, 'borderColor'=>(('N' == $isOn])?'9B9B9B':'000000'), 'vAlign'=> 'center', 'backgroundColor'=>(($isOptional)?'D2D2D2':'FFFFFF'), 'border'=>'single'); $table []= array($descriptionCell, $valueCell); $trProperties []= array('cantSplit'=>true); $tableOptions = array('font'=>'Arial','tableAlign'=>'left'); $docx->addTable($table, $tableOptions, $trProperties); The cell content could not be HTML content only text content. I tired to add this: $text[] = array('text'=>$docx->addBreak(array('type'=>'line'))); but not helpd. Could you give me any soultion on this problem? Thank you

Posted by admin  · 23-02-2015 - 07:46

Hello, To add a line break you need to write '\n' as a literal string in a text string. Please check the included example and the available documentation. If you need further support please write to contact@phpdocx.com Regards.

Posted by Sven May  · 23-02-2015 - 08:07

I am sorry about my question...I missed this addText() property: lineBreak...so it works more than excelent. Thank you!