title: How to save all pages of a Word document as image?
body: <p>I try to save all pages of a Word document as an Enhanced Metafile (.emf) image using the following code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Windows.Forms;
  using System.IO;
  using word = Microsoft.Office.Interop.Word;
  using System.Drawing.Imaging;
  using System.Drawing;
  
  namespace WordToImg
  {
      static class Program
      {
          [STAThread]
          static void Main()
          {
              OpenFileDialog ofd = new OpenFileDialog();
              ofd.Filter = "Doc|*.doc;*.docx";
              ofd.Title = "Select file to convert";
              ofd.InitialDirectory=Application.StartupPath;
              if (ofd.ShowDialog()==DialogResult.OK)
              {
                  string file = ofd.FileName;
                  word.Application app = new word.Application();
                  word.Document doc = app.Documents.Open(file);
  
                  byte[] bytes = (byte[])app.ActiveDocument.Content.EnhMetaFileBits;
                  if (bytes != null)
                  {
                      MemoryStream ms = new MemoryStream(bytes);
                      Image temp = Image.FromStream(ms);
                      temp.Save(Path.GetDirectoryName(file) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file) + ".png", ImageFormat.Png);
                  }
                  doc.Close(false);
                  doc = null;
                  app.Quit();
                  GC.Collect();
              }
          }
      }
  }
  </code></pre>
  
  <p>However, the created metafile only contains the contents of the first page. Is there a way to get the entire document contents as image? Or, maybe, get the contents of each page separately using <code>Content.EnhMetaFileBits</code>?</p>