This short tutorial shows you how to convert DOCX to TIFF with Java REST API. DOCX is a file format created by Microsoft Word, and is used for word processing documents. It is an XML-based standard for creating and storing documents, and is the successor to the DOC format. DOCX files can be opened by Microsoft Word, and most other word processors, including Open Office and Apple Pages.
While, TIFF (Tagged Image File Format) is a file format for storing raster graphics images, popular among graphic artists, the publishing industry and photographers. It can be used to store bitmapped images up to 4GB in size and offers support for layers and multiple pages. TIFF files are also used to store high-quality graphics and can be compressed using lossless compression. If you need DOCX to TIFF Conversion in Java Low Code API then this can be achieved with the help of the following snippet.
Prerequisite
- Create account and get API credentials
- Download Aspose.Words Cloud SDK for Java
- Setup Java project with the above SDK
Steps to Convert DOCX to TIFF in Java REST API
- Set Client ID and Client Secret for the API
- Create an object of WordsAPI class with client credentials
- Specify input and output files
- Read input DOCX file and upload to cloud storage
- Create an instance of WordsAPI with input and output file formats
- Call convertDocument method to Convert DOCX to TIFF using REST API
- Save the output TIFF file on local disk
Code for DOCX to TIFF Conversion in Java Low Code API
String ClientID = Client.getID(); //replace Client.getID() with your own client ID here | |
String ClientSecret = Client.getSecret(); //replace3 Client.getSecret() with your own client secret here | |
String APIBaseUrl="https://api.aspose.cloud"; | |
String Local_Path = "C:/Temp/"; | |
try { | |
//Create API client with credentials | |
ApiClient apiClient = new ApiClient(ClientID, ClientSecret, APIBaseUrl); | |
//Create SDK object | |
WordsApi wordsApi = new WordsApi(apiClient); | |
String inputFile = "DOCXToTIFF.docx"; | |
String outputFile = "DOCXToTIFF.tiff"; | |
String outputFormat = "tiff"; | |
//Read input file to bytes array | |
byte[] inputFileData = Files.readAllBytes(Paths.get(Local_Path + inputFile).toAbsolutePath()); | |
//create conversion request object with input and output files | |
ConvertDocumentRequest convertDocumentRequest = new ConvertDocumentRequest(inputFileData, outputFormat, null, null, null, null, null, null, null); | |
//convert the input file to output format | |
byte[] outputFileData = wordsApi.convertDocument(convertDocumentRequest); | |
//save the output file from the bytes array | |
FileOutputStream fileOutputStream = new FileOutputStream(Local_Path + outputFile); | |
fileOutputStream.write(outputFileData); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} |
The code sample shown above helps you to convert DOCX to TIFF with Java REST API. You just need to upload DOCX file with the help of the Aspose.Words REST API SDK and download output TIFF file to save it locally.
The above DOCX to TIFF Conversion could be utilized with any no code or low code apps on any platform.
A similar feature can be found in the following topic: How to Convert PDF to DOCX with Java REST API