title: Generate a Word document in JavaScript with Docx.js?
body: <p>I am trying to use <a href="https://raw.github.com/stephen-hardy/DOCX.js/master/docx.js" rel="nofollow noreferrer">docx.js</a> to generate a Word document but I can't seem to get it to work.</p>
  
  <p>I copied the raw code into the Google Chrome console after amending line 247 to fix a "'textAlign' undefined error"</p>
  
  <pre><code>if (inNode.style &amp;&amp; inNode.style.textAlign){..}
  </code></pre>
  
  <p>Which makes the function <code>convertContent</code> available. The result of which is an Object e.g.</p>
  
  <pre><code>JSON.stringify( convertContent($('&lt;p&gt;Word!&lt;/p&gt;)[0]) )
  </code></pre>
  
  <p>Results in -</p>
  
  <pre><code>"{"string":
        "&lt;w:body&gt;
              &lt;w:p&gt;
                  &lt;w:r&gt;
                      &lt;w:t xml:space=\"preserve\"&gt;Word!&lt;/w:t&gt;
                  &lt;/w:r&gt;
              &lt;/w:p&gt;
         &lt;/w:body&gt;"
   ,"charSpaceCount":5
   ,"charCount":5,
   "pCount":1}"
  </code></pre>
  
  <p>I copied </p>
  
  <pre><code>&lt;w:body&gt;
      &lt;w:p&gt;
          &lt;w:r&gt;
              &lt;w:t xml:space="preserve"&gt;Word!&lt;/w:t&gt;
          &lt;/w:r&gt;
      &lt;/w:p&gt;
  &lt;/w:body&gt;
  </code></pre>
  
  <p>into Notepad++ and saved it as a file with an extension of 'docx' but when I open it in MS Word but it says 'cannot be opened because there is a problem with the contents'.</p>
  
  <p>Am I missing some attribute or XML tags or something?</p>