title: C#: Inserting HTML content -> MS Word: images & tables autoscaling (i.e losing width & height style attributes)
body: <p>I am using C# to generate reports in MS Word. I have a predefined .docx template and I use mail merge fields which are then updated by my app.</p>
  
  <p>I retrieve small sections of HTML content from a database and insert them into the appropriate points in the MS Word document as follows:</p>
  
  <ol>
  <li><p>I retrieve the HTML content</p></li>
  <li><p>I wrap the content with tags:</p>
  
  <p><code>&lt;HTML&gt;
      &lt;TITLE&gt;&lt;/TITLE&gt;
      &lt;BODY&gt;
      ... content ...
      &lt;/BODY&gt;
   &lt;/HTML&gt;</code></p></li>
  <li><p>Save html content into a temporary file</p></li>
  <li><p>Use the Word._Application.Selection.InsertFile() method to insert the HTML file</p></li>
  </ol>
  
  <p>Example of converted HTML code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;body&gt;
      &lt;table border="0" cellpadding="0" cellspacing="0" style="width: 700px; "&gt;
      &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td style="padding-top: 0cm; padding-right: 5.4pt; padding-bottom: 0cm; padding-left: 5.4pt; text-align: center; vertical-align: middle; width: 150px; "&gt;
              &lt;img alt="see attached image: screenshot-3.jpg" src="XXXXX/screenshot-3.jpg" style="width: 60px; height: 84px; " /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;br /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The above system works, but I find that tables and images are 'auto-scaled' by MS Word, with images being rendered with their original dimensions as opposed to the embedded style="width, height" attributes.</p>
  
  <p>My HTML is rendered 100% in a browser, but not in MS Word.</p>
  
  <p>Any ideas on how to get my scaling right would be most appreciated.</p>
  
  <p>Many thanks </p>