Image appears everywhere in our daily life. Comparing with plain text, image is more appealed to people. Therefore, it seems that images become one of the most important parts of advertisements, booklets and many electronic documents, even e-books and magazines.
Generally speaking, there are many methods to have an image, for example, to draw, print screen or find one from internet. Also, sometimes, we can find that the contract which is sent to partner is not an electronic file but an image because image is difficult to edit. At that time, people may need to convert a document to image firstly.
In this post, I will share a method about how to convert Word to Image with C#/VB.NET. Actually, there are several formats for image, and I set the image format which is converted from Word as .jpg.
What’s more, I use a component, Spire.Doc for .NET to realize conversion more quickly and easily. So I have added its dll file as reference in my project at the beginning.
Detailed Steps Shown as Following:
I. Load document which I want to convert to image from computer by using document.LoadFromFile() method.
Document document = new Document();
Dim document As New Document()
II. Declare image and define its location and image type by using document.SaveToImages() method. Two parameters should be passed to this method, page index and image type.
Image image = document.SaveToImages(0, ImageType.Metafile);
Dim image As Image = document.SaveToImages(0, ImageType.Metafile)
III. Save image by using image.Save() method and launch this image.
Note: Because the image type is set as Metafile in step 2, so the image format cannot be set as .bmp and .tiff. For ,bmp and .tiff format, please change image type as bitmap (ImageType.Bitmap)
For DOC to image, just need to change the file format as .doc which is loaded in first step.
Result Shown as Following: