title: adding images to openxml doc created from altchunk
body: <p>I need an automated process for creating docx files from xhtml source. The xhtml files contain images (<code>&lt;img&gt;</code> elements) whose "src" attributes point to an external reference. But the docx files need to be readable without a network connection, so I need to find a way to embed the images directly into the docx package (namely, in the /media folder).</p>
  
  <p>So far I've used the altChunk method (as described by <a href="http://blogs.msdn.com/ericwhite/archive/2008/10/27/how-to-use-altchunk-for-document-assembly.aspx" rel="nofollow noreferrer">Eric White</a>) to create the .docx file. I had hoped to use the OpenXML SDK to insert the image parts into the package. But to do that I need to insert paragraphs (<code>&lt;p&gt;</code> nodes) into the document. Unfortunately the document part contains nothing but a reference to the altChunk (stored separately in the docx package). Of course, once the docx is opened, edited and saved, the altChunk part is removed and it’s contents are embedded properly in the document.xml. But I don’t know of any way to do that programatically, so that doesn't help.</p>
  
  <p>Other options I’ve considered: </p>
  
  <ol>
  <li>Partitioning the xhtml into segments, separated between each image, then adding each altChunk one at a time, with the appropriate image reference between each one. (Tedious but seems possible)</li>
  <li>Inserting the images into the media folder, and then find way to embed WordProcessingML directly into the xhtml so that the <code>&lt;img&gt;</code> references the packaged image file. (Questionable at best)
  Can anyone think of a better approach?</li>
  </ol>