Syncfusion Feedback

Word to Image Conversion Using the Syncfusion .NET Word Library

The Syncfusion® .NET Word Library offers comprehensive APIs to convert a Word document into an image programmatically with a few lines of code and without Microsoft Word or interop dependencies. It allows you to convert individual pages or the entire document into images.

Watch this video to learn how to convert a Word document to images using the Syncfusion .NET Word Library.

Watch the video

Convert Word to images using C#

Learn how to convert Word documents to images programmatically using C# with the Syncfusion .NET Word Library. This guide demonstrates converting individual pages or entire documents into image formats.

Step 1: Create a new project

Start by creating a new C# Console Application project.

Step 2: Install the NuGet package

Add the Syncfusion.DocIORenderer.Net.Core package to your project from NuGet.org.

Step 3: Add required namespaces to convert Word to images

Add the following namespaces to your Program.cs file:

using System.IO;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;

Step 4: Open the Word document

Open an existing Word document for conversion to images.

FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open);
 //Load an existing Word document
 WordDocument wordDocument = new WordDocument(fileStream, FormatType.Automatic);

Step 5: Convert Word document page to image

Create a DocIORenderer instance and convert the first page of the Word document into an image stream.

Run

//Create an instance of DocIORenderer
DocIORenderer renderer = new DocIORenderer();
//Convert the first page of the Word document into an image
Stream imageStream = wordDocument.RenderAsImages(0, ExportImageFormat.Jpeg);

Step 6: Save the output image

Save the converted image stream to an output file.

//Create the output image file stream
 FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output.jpeg"));
 //Copy the converted image stream into created output stream
 imageStream.CopyTo(fileStreamOutput);
 // Close resources explicitly
 fileStreamOutput.Close();
 imageStream.Close();
 wordDocument.Close();
 fileStream.Close();

Get started quickly by downloading the installer and checking license information on the Downloads page.

Syncfusion .NET Word Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.