title: PHPWord LineBreak in TextRun not working
body: <p>I found advice from an older <a href="https://stackoverflow.com/questions/17689188/phpword-how-to-add-text-break-new-line-while-in-a-text-run">Stack Over Flow Question</a> and I am having problems getting it to work.  I added the methods where they described but the generated word file does not have the linebreaks (visually and by inspecting the docx file after unzipping it).  There are no errors so the method seems to be doing something just not what I want.  I am doing this since I need <code>\n</code> characters and I did get this to work fine using PHPRtfText but had issues with compatibility and it seems to work better as Word2007 files so I converted the code accordingly.  Though, maybe I placed it in the wrong spot, but here is the modified function:</p>
  
  <p><strong>/lib/PHPWord/Writer/Word2007/Base.php:</strong></p>
  
  <pre><code>protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null,    PHPWord_Section_TextRun $textrun)
  {
    $elements = $textrun-&gt;getElements();
    $styleParagraph = $textrun-&gt;getParagraphStyle();
  
    $SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
  
    $objWriter-&gt;startElement('w:p');
  
    if($SpIsObject)
    {
       $this-&gt;_writeParagraphStyle($objWriter, $styleParagraph);
    }
    elseif(!$SpIsObject &amp;&amp; !is_null($styleParagraph))
    {
       $objWriter-&gt;startElement('w:pPr');
          $objWriter-&gt;startElement('w:pStyle');
             $objWriter-&gt;writeAttribute('w:val', $styleParagraph);
          $objWriter-&gt;endElement();
       $objWriter-&gt;endElement();
    }
  
    if(count($elements) &gt; 0)
    {
       foreach($elements as $element)
       {
          if($element instanceof PHPWord_Section_Text)
          {
             $this-&gt;_writeText($objWriter, $element, true);
          }
          elseif($element instanceof PHPWord_Section_Link)
          {
             $this-&gt;_writeLink($objWriter, $element, true);
          }
       }
    }
    elseif($element instanceof PHPWord_Section_TextBreak)
    {
       $objWriter-&gt;writeElement('w:br');
    }
  
    $objWriter-&gt;endElement();
  }
  </code></pre>
  
  <p>I am invoking it by:</p>
  
  <p><strong>test1.php:</strong></p>
  
  <pre><code>$PHPWord = new PHPWord();;
  $PHPWord-&gt;setDefaultFontName('Calibri');
  $PHPWord-&gt;setDefaultFontSize(11);
  
  $section = $PHPWord-&gt;createSection();
  $textrun = $section-&gt;createTextRun();
  $textrun-&gt;addText( "---------------");
  $textrun-&gt;addTextBreak();
  $textrun-&gt;addText( "$name", array('bold'=&gt;true ) );
  </code></pre>
  
  <p>And lastly in <strong>/lib/PHPWord/Section/TextRun.php:</strong></p>
  
  <pre><code>public function addTextBreak($count = 1)
  {
      for($i=1; $i&lt;=$count; $i++)
      {
          $this-&gt;_elementCollection[] = new PHPWord_Section_TextBreak();
      }
  }
  </code></pre>
  
  <p>Is there anything else I can add to help?  I really need this to work and cannot change the class again to something else.</p>
  
  <p>I am heavily formatting the text, thus the textrun, but I need the <code>\n</code> after each line not a section as it needs to be the same paragraph, so having <code>\n\n</code> is not going to be acceptable for this endeavour.</p>