If you need to convert Word documents to image formats programmatically, let me introduce a high-quality conversion solution in Java to convert Word to PNG, JPG, BMP, GIF, or TIFF images.

Convert Word DOC to PNG, JPEG, BMP, GIF, or TIFF in Java

In various cases, you need to display MS Word documents in your applications programmatically. One of the most convenient ways in such scenarios is the conversion from DOCX/DOC to image formats. To accomplish that, you can convert Word DOC or DOCX files to PNG, JPEG, BMP, GIF, or TIFF images.

Java Library to Convert Word to Image

To convert Word documents to image formats, we will use Aspose.Words for Java. It is a feature-rich API to create, edit, or convert MS Word documents in Java-based applications. You can download the API’s JAR or install it using the following Maven configurations:

Repository:

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>

Dependency:

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words</artifactId>
    <version>22.11</version>
    <classifier>jdk17</classifier>
</dependency>

How to Convert a Word to PNG, JPEG, BMP, GIF, or TIFF in Java

You can convert a Word document into PNG, JPEG, BMP, GIF, or TIFF images depending on your requirement. To set the output image format, SaveFormat enum is used. For demonstration, let’s convert a Word DOCX file to PNG images in Java.

Java Code to Convert Word DOC to Image

The following code sample shows how to convert Word DOCX to PNG images in Java.

Java DOCX to Image - Customization

You can also customize the Word to image conversion using different options. For example, you can set horizontal resolution, vertical resolution, overall resolution, scale, pixel format, brightness, color mode, contrast, etc. The following are the steps to customize Word to image conversion in Java.

  • Load the Word document using the Document class.
  • Create an instance of ImageSaveOptions class and specify the output image format.
  • Set desired options such as brightness, contrast, etc. using the ImageSaveOptions object.
  • Loop through the pages in the document.
  • Convert each page to image using Document.save(string, ImageSaveOptions) method.

The following code sample shows how to customize Word to JPEG image conversion using different options.

Free Word to Image Converter

You can get a free temporary license and convert Word documents to image formats without evaluation limitations.

Conclusion

In this article, you have learned how to convert Word documents to PNG, JPEG, BMP, GIF, or TIFF images in Java with high speed and quality. Furthermore, you have seen how to customize Word to image conversion using different options. Apart from that, you can explore other features of Aspose.Words for Java using the documentation. Also, you can post your questions on our forum.

See Also