title: OpenXml-SDK: How to apply FontFamily/Size to AltChunk of Type [TextPlain]
body: <p>Can anybody show me how to apply Fontfamily/size to an AltChunk of Type </p>
  
  <pre><code>AlternativeFormatImportPartType.TextPlain
  </code></pre>
  
  <p>This is my Code, but I can´t figure out how to do this at all (even Google doesn´t help)</p>
  
  <pre><code>MainDocumentPart main = doc.MainDocumentPart;
  string altChunkId = "AltChunkId" + Guid.NewGuid().ToString().Replace("-", "");
  var chunk = main.AddAlternativeFormatImportPart
      (AlternativeFormatImportPartType.TextPlain, altChunkId);
  
  using (var mStream = new MemoryStream())
  {
      using (var writer = new StreamWriter(mStream))
      {
          writer.Write(value);
          writer.Flush();
          mStream.Position = 0;
          chunk.FeedData(mStream);
      }
  }
  
  var altChunk = new AltChunk();
  altChunk.Id = altChunkId;
  
  OpenXmlElement afterThat = null;
  foreach (var para in main.Document.Body.Descendants&lt;Paragraph&gt;())
  {
      if (para.InnerText.Equals("Notizen:"))
      {
          afterThat = para;
      }
  }
  
  main.Document.Body.InsertAfter(altChunk, afterThat);
  </code></pre>
  
  <p>if I do it this way I get "Courier New" with a Size of "10,5"</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This is the working Solution I came up with:</p>
  
  <p>Convert Plaintext to RTF, change the Fontfamily/size and apply it to the WordProcessingDocument!</p>
  
  <pre><code>public static string PlainToRtf(string value)
  {
      using (var rtf = new System.Windows.Forms.RichTextBox())
      {
          rtf.Text = value;
          rtf.SelectAll();
          rtf.SelectionFont = new System.Drawing.Font("Calibri", 10);
  
          return rtf.Rtf;
      }
  }
  
  var chunk = main.AddAlternativeFormatImportPart
          (AlternativeFormatImportPartType.Rtf, altChunkId);
  
  using (var mStream = new MemoryStream())
  {
      using (var writer = new StreamWriter(mStream))
      {
          var rtf = PlainToRtf(value);
          writer.Write(rtf);
          writer.Flush();
          mStream.Position = 0;
          chunk.FeedData(mStream);
      }
  }
  //proceed with creating AltChunk and inserting it to the Document...
  </code></pre>