title: c# openxml : copy paragraph with font and alignment
body: <p>I want to copy a part of word *.docx to another *.docx file. For this I get a list of paragraphs from the original file :</p>
  
  <pre><code>private static List&lt;Paragraph&gt; getTextItems( string origFile )
  {
      List&lt;Paragraph&gt; paragraphItems = new List&lt;Paragraph&gt;();
      var parser = new LineTextParser();
  
      using (var doc = WordprocessingDocument.Open( origFile, false))
      {
  
          foreach (var el in doc.MainDocumentPart.Document.Body.Elements().OfType&lt;Paragraph&gt;())
          {
              if (parser.isHorizontalTableLine(el.InnerText))
              {
                  if (true == el.InnerText.EndsWith("|"))
                  {
                      break;
                  }
              }
              paragraphItems.Add(el);
          }
      }
  
      return paragraphItems;
  }
  </code></pre>
  
  <p>Then I'm trying to apply these items to a new file :</p>
  
  <pre><code>    using (WordprocessingDocument wordDocument =
          WordprocessingDocument.Create(resultFile, WordprocessingDocumentType.Document))
      {
          // Add a main document part. 
          MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
  
          // Create the document structure and add some text.
          mainPart.Document = new Document();
          Body body = mainPart.Document.AppendChild(new Body());
          foreach (var item in paragraphItems)
          {
              Paragraph para = body.AppendChild(new Paragraph() );
              para.Append(item.ParagraphProperties.CloneNode(true));
              Run run = para.AppendChild(new Run());
              run.AppendChild(new Text(item.InnerText));
          }
      }
  </code></pre>
  
  <p>But original formatting is lost - I mean the font has been changed and also alignment. What is the solution here?</p>