TIFF is a popular format to store multiple images in the form of pages. This distinguishing feature of the TIFF format allows sharing of Word documents in a read-only format. We can easily convert Word documents (DOC or DOCX) to TIFF images programmatically in Java applications. In this article, we will learn how to convert a Word document to a TIFF image using Java.
The following topics shall be covered in this article:
- Java API to Convert Word to TIFF
- Convert Word Document to TIFF in Java
- Customize Word to TIFF Conversion in Java
Java API to Convert Word to TIFF
For converting DOC to TIFF or DOCX to TIFF, we will be using Aspose.Words for Java API. It enables us to generate, modify, convert, render and print Word documents without utilizing Microsoft Word directly within cross-platform applications. Please either download the JAR of the API or add the following pom.xml configuration in a Maven-based Java application.
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>https://repository.aspose.com/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-words</artifactId> <version>22.4</version> <type>pom</type> </dependency>
Convert Word Document to TIFF in Java
We can convert a Word document to a multipage TIFF by following the steps given below:
- Load a Word document using the Document class.
- Save the document as a TIFF file using the Save() method. It takes the path of the output file and SaveFormat as arguments.
The following code sample shows how to convert a Word document to a TIFF using Java.
Customize Word to TIFF Conversion in Java
We can customize the conversion of Word documents to TIFF by applying various options provided by the API. For this purpose, the API provides the ImageSaveOptions class. It allows setting the image brightness, resolution, range of pages to convert, compression scheme, and so on. Please follow the steps mentioned below to set additional options while converting Word to TIFF.
- Firstly, load a Word document using the Document class.
- Next, create an instance of the ImageSaveOptions class with the input image format as an argument.
- After that, set the desired options such as TiffCompression, Resolution, etc.
- Finally, call the Save(string, ImageSaveOptions) method to convert Word to TIFF.
The following code sample shows how to convert a Word document to a TIFF image with additional options.
Get a Free License
Please try the API without evaluation limitations by requesting a free temporary license.
In this article, we have learned how to convert a Word document to a TIFF image using Java. We have also seen how to apply additional options such as TIFF compression, brightness, and image resolution programmatically. Besides, you can learn more about Aspose.Words for Java API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.