The simplest way to convert DOCX to a set of Images in .Net C# app

Hi Developers,

In this topic you will find a simplest solution to convert DOCX to Images(PNG, JPEG, TIFF, any) in C#.
To start please download these components:

  1. Download UseOffice .Net
  2. Download PDF Focus .Net
using System;
using System.IO;
using System.Collections;

namespace Sample
    class Program

        static void Main(string[] args)
            Console.WriteLine("Convert DOCX file to set of PNG images");

            string pathToDocx = @"D:\simple text.docx";
            // We need this pdf as bridge between docx and images.
            // We remove this pdf file after conversion
            string pathToPdf = Path.ChangeExtension(pathToDocx, ".pdf");
            string pathToImages = Path.GetDirectoryName(pathToDocx);
            string imagePageName = "Page";
            int result = -1;

            // 1. DOCX to PDF
            SautinSoft.UseOffice u = new SautinSoft.UseOffice();
            //Prepare UseOffice .Net, loads MS Word in memory
            if (u.InitWord() == 0)
                result = u.ConvertFile(pathToDocx, pathToPdf, SautinSoft.UseOffice.eDirection.DOCX_to_PDF);
                //Release MS Word from memory
            if (result != 0)
                Console.WriteLine("Converting failed on stage DOCX to PDF!");

            // 2. PDF to Images
            SautinSoft.PdfFocus p = new SautinSoft.PdfFocus();
            if (p.PageCount > 0)
                p.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
                p.ImageOptions.Dpi = 200;
                p.ImageOptions.ColorDepth = SautinSoft.PdfFocus.CImageOptions.eColorDepth.Rgb24bpp;
                p.ToImage(pathToImages, imagePageName);
                Console.WriteLine("{0} page(s) converted successfully!");
                Console.WriteLine("Converting failed on stage PDF to Images!");


Download code: DocxToImages.cs.

I hope this will be helpful to you, anyway if you need a C# code sample to convert between various documents, email me at:

Best wishes,
Max (C# developer)

Leave a Comment

Your email address will not be published.