Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-cloud-kb/54e1658076d7bcd4bbea6ac9fbe2c36b to your computer and use it in GitHub Desktop.
Save aspose-cloud-kb/54e1658076d7bcd4bbea6ac9fbe2c36b to your computer and use it in GitHub Desktop.
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());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment