How to Convert Word Document to Images in C#

With Aspose.Words for .NET, you can convert document e.g. DOCX, DOC, RTF, ODT, HTML to image file formats e.g. PNG, JPEG, BMP, GIF. In this tutorial you will learn how to convert Word document to images in C#.

Steps to Convert Word Document to Images in C#

  1. Install Aspose.Words for .NET package from NuGet.org
  2. Add reference to Aspose.Words and Aspose.Words.Saving namespaces
  3. Set license of Aspose.Words for .NET using License.SetLicense method
  4. Import the input document into Aspose.Words’ DOM
  5. Create instance of ImageSaveOptions class to specify options when rendering document pages to images
  6. Implement IPageSavingCallback interface and set file name path using PageSavingArgs.PageFileName property
  7. Set Word document’s pages range for image conversion
  8. Finally, save the images to disk using Document.Save method

You often need to use different fonts formatting and styles when working with documents. If you open a document on a machine where used fonts in the document are not installed, the text representation will be different in document viewer. The case will be same for Aspose.Words. It requires TrueType fonts when rendering document to fixed-page formats (JPEG, PNG, PDF or XPS). The fonts used in the input document should be installed on the machine where you want to convert word document to images.

Previously, we looked into how to print Word document using C# in another how-to topic. This topic explains all steps to convert Word document to images in C#

Code to Convert Word Document to Images in C#

The above code in C# converts word document to images without installing MS Office. You can use it where .NET is installed at Windows, Linux, macOS, and cloud platforms (Amazon Web Services and Microsoft Azure).

 English