title: Add Image to Word Docx using NPOI Library C#
body: <p>I was already using the NPOI Library for creating Excel Documents(which is the .NET version of POI Java project), but now I also want to create a Word (Docx document). </p>
  
  <p>I want to add an image to the document, but somehow it won't work. It looks like it's adding the image, but when I open the downloaded doc</p>
  
  <p><code>“The file &lt;document filename&gt; cannot be opened because there are problems with the contents”</code></p>
  
  <p>this is the code for adding the image in the document:</p>
  
  <pre><code>XWPFParagraph p2 = wordDoc.CreateParagraph();
  XWPFRun r2 = p2.CreateRun();
  r2.AddPicture(pictureData, (int)PictureType.PNG, "image1", 800, 600);
  </code></pre>
  
  <p>where pictureData is a memoryStream of the pictureData. the memoryStrean is correct, because I can get the base64 String from it and this shows the correct output, but all I want is this image into a word document.</p>
  
  <p>So my question is, what am I missing, what am I doing wrong? Couldn't find any documentation about images into a XWPF document.</p>
  
  <p>thanks in advance</p>