The Syncfusion Blazor Word Library (DocIO) offers powerful and comprehensive APIs to convert a Word document into an image programmatically with a few lines of code without Microsoft Word or interop dependencies. It allows you to generate an entire document as images or a single page of a Word document as an image to provide the document’s preview, thumbnail, or to print it.
Convert complex Word documents into image files faster in a batch process, compared to Office automation libraries.
Convert Word documents to image files in partial trust environments like Azure and AWS.
A non-UI component to automate conversion of Word documents to images in .NET Framework, .NET Core, Blazor, Xamarin, and .NET MAUI applications.
Convert a specific page in a Word document into an image.
Convert a specified range of pages in a Word document into images.
The built-in font substitution event allows users to choose alternate fonts from the device or upload fonts with a few lines of code.
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
//Load file stream into Word document.
using (WordDocument wordDocument = new WordDocument(wordDocumentStream, FormatType.Automatic))
{
//Create a new instance of DocIORenderer class.
using (DocIORenderer render = new DocIORenderer())
{
//Convert the entire Word document to images.
Stream[] imageStreams = wordDocument.RenderAsImages();
//Save the stream as file.
for (int i = 0; i < imageStreams.Length; i++)
{
using (FileStream fileStreamOutput = File.Create("WordToImage_" + i + ".jpeg"))
imageStreams[i].CopyTo(fileStreamOutput);
}
}
}
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using (WordDocument wordDocument = new WordDocument(wordDocumentStream, FormatType.Automatic))
{
using (DocIORenderer render = new DocIORenderer())
{
//Convert the first page of the Word document into an image.
Stream imageStream = wordDocument.RenderAsImages(0, ExportImageFormat.Jpeg);
using (FileStream fileStreamOutput = File.Create("WordToImage.jpeg"))
imageStream.CopyTo(fileStreamOutput);
}
}
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using (WordDocument wordDocument = new WordDocument(wordDocumentStream, FormatType.Automatic))
{
using (DocIORenderer render = new DocIORenderer())
{
//Convert a specific range of pages in Word document to images.
Stream[] imageStreams = wordDocument.RenderAsImages(1, 2);
for (int i = 0; i < imageStreams.Length; i++)
{
using (FileStream fileStreamOutput = File.Create("WordToImage_" + i + ".jpeg"))
imageStreams[i].CopyTo(fileStreamOutput);
}
}
}
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.