Convert Word to Images (PNG, JPG, TIFF and SVG) using Java
Tags: java, convert, word, images
Published: 2021-09-09 01:44:55

---
title: Convert Word to Images (PNG, JPG, TIFF and SVG) using Java
published: true
description: This article describes how to convert Word document to images (PNG, JPG, TIFF and SVG) using Java.
tags: Java, Convert, Word, Images
//cover_image: https://direct_url_to_image.jpg
---
Images are used almost everywhere in our daily life. For various purposes, you may need to convert documents in other formats like Word DOC/DOCX to images. In this article, I am going to describe how to convert Word document to image formats such as PNG, JPG, TIFF and SVG using Java and Spire.Doc for Java library.

Before running the following examples, you need to add dependencies for including [Spire.Doc for Java](https://www.e-iceblue.com/Download/doc-for-java.html) library in your Java project.
##Convert Word to PNG/JPG##
Spire.Doc for Java uses the **saveToImages** method of **Document** class to convert Word document to PNG/JPG images. 

The Document class provides several overloads for saveToImages method which you can use to convert Word document to images, or convert particular page(s) of a Word document to images, furthermore, you can also specify the resolution of the images when performing conversion.

The following example shows how to convert a Word document to PNG images.
```java
import com.spire.doc.Document;
import com.spire.doc.documents.ImageType;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class ConvertWordToPngOrJpg {
    public static void main(String[] args) throws IOException {

        //Create a Document instance
        Document document = new Document();
        //Load a Word document
        document.loadFromFile("Sample.docx");

        //Save the document to PNG images
        BufferedImage[] images = document.saveToImages(ImageType.Bitmap);
        for(int i = 0; i < images.length; i++)
        {
            BufferedImage image = images[i];
            File file = new File( "images/" + String.format(("Img-%d.png"), i));
            ImageIO.write(image, "PNG", file);
        }
    }
}
```
The converted PNG images:
![Convert Word to PNG/JPG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zniq17esivqkf8itaq22.png)
##Convert Word to TIFF##
Spire.Doc for Java provides the ability to convert Word document to multi-page TIFF by using the **saveToTiff** method of Document class. The saveToTiff method accepts the following parameter:
**String**: the converted TIFF file name.

The following example shows how to convert a Word document to TIFF.
```java
import com.spire.doc.Document;

public class ConvertWordToTiff {
    public static void main(String[] args){

        //Create a Document instance
        Document document = new Document();
        //Load a Word document
        document.loadFromFile("Sample.docx");

        //Save the document to TIFF
        document.saveToTiff("toTIFF.tiff");
    }
}
```
The converted TIFF:
![Convert Word to Multi-Page TIFF](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjbpozq30nsjo7jmjjm5.png) 
##Convert Word to SVG##
To convert a Word document to SVG, use the **saveToSVG** method of Document class. The saveToSVG method accepts the following parameter:
**String**: the converted SVG file name.

The following example shows how to convert a Word document to SVG.
```java
import com.spire.doc.Document;

public class ConvertWordToSvg {
    public static void main(String[] args){

        //Create a Document instance
        Document document = new Document();
        //Load a Word document
        document.loadFromFile("Sample.docx");

        //Save the document to SVG
        document.saveToSVG("toSVG.svg");
    }
}
```
The converted SVG:
![Convert Word to SVG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itnqe4b542vcrtdkcv31.png)