Word to TIFF Document Conversion using Java | DOC to TIFF

Word to TIFF Document
Convert Word to TIFF Document online | DOC to TIFF conversion using Java

This article explains the details of how we can load a Word file and convert it to a TIFF Document using Java SDK. We understand that when using the TIFF format, it has an alpha channel that, in addition to the color information, can also store the transparency of individual pixels. The advantage of this method is the simple and therefore fast compression and decompression of such files with lossless quality. We are going to discuss the following topics in more detail

Word Conversion API

We are going to use Aspose.Words Cloud SDK for Java to perform the document conversion operations. The SDK is available for download at Maven and GitHub. As we are going to download the SDK from Maven, so please add the following lines to pom.xml in your Maven build project.

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words-cloud</artifactId>
    <version>22.4.0</version>
    <type>pom</type>
</dependency>

We also need to create a free account by visiting Aspose.Cloud dashboard, so that we can manage our documents in cloud storage.

Convert Word to TIFF Document in Java

The following section defines the steps on how to load a Word document from cloud storage and convert it to a TIFF image. After the conversion, the resultant image is stored in the same cloud storage.

  • Firstly, create an object of ApiClient which takes client credentials as arguments.
  • Then create an instance of WordsApi while passing ApiClient object as an argument
  • In order to specify the name of the resultant TIFF, we are going to use setFileName(…) method of TiffSaveOptionsData class
  • As we are currently interested to convert the only single page of 1st index from a word document, we are going to specify the index values
  • Penultimate, we need to create an object of SaveAsTiffRequest where we pass TiffSaveOptionsData object, page index values, and other optional parameters
  • Finally, perform the conversion by calling saveAsTiff() method of WordsApi class while passing SaveAsTiffRequest object as an argument.

Word DOC to TIFF Conversion using cURL Commands

Let’s discuss the details on how to convert the Word doc to a TIFF image using cURL commands. Owing to the REST architecture of APIs, we can access them via cURL commands. So the first step is to generate a JWT access token based on our client credentials. Please execute the following command to generate the JWT Token.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have the JWT token, we can use the following cURL command to access the word document stored in cloud storage and render it to TIFF format.

curl -v -X PUT "https://api.aspose.cloud/v4.0/words/test_multi_pages.docx/saveAs/tiff?pageCount=1&pageIndex=0&tiffBinarizationMethod=FloydSteinbergDithering" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{\"FileName\":\"converted.tiff\",\"SaveFormat\":\"tiff\",\"AllowEmbeddingPostScriptFonts\":true,\"DmlRenderingMode\":\"Fallback\",\"DmlEffectsRenderingMode\":\"Simplified\",\"ImlRenderingMode\":\"Fallback\",\"ZipOutput\":false,\"UpdateLastSavedTimeProperty\":true,\"UpdateSdtContent\":true,\"UpdateFields\":true,\"Dml3DEffectsRenderingMode\":\"Basic\",\"UpdateCreatedTimeProperty\":true,\"UpdateLastPrintedProperty\":true,\"FlatOpcXmlMappingOnly\":true,\"ColorMode\":\"Normal\",\"JpegQuality\":0,\"MetafileRenderingOptions\":{\"EmfPlusDualRenderingMode\":\"EmfPlusWithFallback\",\"EmulateRasterOperations\":true,\"RenderingMode\":\"VectorWithFallback\",\"UseEmfEmbeddedToWmf\":true,\"ScaleWmfFontsToMetafileSize\":true},\"NumeralFormat\":\"European\",\"OptimizeOutput\":true,\"PageCount\":0,\"PageIndex\":0,\"HorizontalResolution\":600,\"ImageBrightness\":0,\"ImageColorMode\":\"None\",\"ImageContrast\":0,\"PixelFormat\":\"Format16BppRgb555\",\"Resolution\":100,\"Scale\":1,\"UseAntiAliasing\":true,\"UseGdiEmfRenderer\":true,\"UseHighQualityRendering\":true,\"VerticalResolution\":800,\"ThresholdForFloydSteinbergDithering\":0,\"TiffBinarizationMethod\":\"Threshold\",\"TiffCompression\":\"None\"}"

In order to preview the resultant TIFF, you may consider using our free online Image Viewer App.

Conclusion

We have learned the simple and effective approach for converting MS Word to TIFF document using Java SDK. All the conversion is performed in the cloud while using fewer code lines. Similarly, we have also learned the steps to export Word Doc to TIFF image using cURL commands over the command line terminal. Apart from conversion operations, you may also perform a plethora of useful operations with our Cloud API and their details can be explored in the Programmers Guide. In case you encounter any issues while using the API, please feel free to contact us via free product support forum.

Related Articles

The following articles are highly recommended to learn about: