In this simple and easy tutorial, you’ll understand how to convert PDF to TIFF with Java REST API in the cloud. In order to export PDF to TIFF format, we’re using Aspose.PDF for Java Cloud SDK. If you require PDF to TIFF Conversion in Java Low Code API then this can be carried out by using the following sample code and simple steps.
Prerequisite
- Create account and get API credentials
- Download Aspose.PDF Cloud SDK for Java
- Setup Java project with the above SDK
Steps to Convert PDF to TIFF in Java REST API
- Set Client ID and Client Secret for the API
- Create an instance of pdfApi class with client credentials
- Specify input and output files
- Read input PDF file and upload to cloud storage
- Create an instance of pdfApi with input and output file formats
- Call putPageConvertToTiff method to Convert PDF to TIFF using REST API
- Save the output TIFF file on local disk
Code for PDF 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 | |
try { | |
ApiClient apiClient = new ApiClient(); | |
apiClient.setAppKey(ClientSecret); | |
apiClient.setAppSid(ClientID); | |
PdfApi pdfApi = new PdfApi(apiClient); | |
String inputFile = "PDFtoTIFF.pdf"; | |
String outputFile = "PDFtoTIFF.tiff"; | |
String folder = "Temp"; | |
String format = "TIFF"; | |
// Upload file to cloud storage | |
File file = new File("C:/Temp/" + inputFile); | |
pdfApi.uploadFile(folder + "/" + inputFile, file, null); | |
int pageNumber = 1; | |
pdfApi.putPageConvertToTiff(inputFile, pageNumber, folder + '/' + outputFile, null, null, folder, null, null); | |
// Download output file from Cloud Storage | |
File downloadResponse = pdfApi.downloadFile(folder + "/" + outputFile, null, null); | |
File dest = new File("C:/Temp/" + outputFile); | |
Files.copy(downloadResponse.toPath(), dest.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} |
The code sample shown above helps you to convert PDF to TIFF with Java REST API. You simply have to upload PDF file with the help of the Aspose.PDF REST API SDK for Java and download output TIFF file to save it locally by using Aspose conversion API online.
This PDF to TIFF Conversion could be put to use with any no code or low code apps on any platform.
The following link shows a similar feature that might be helpful to you: How to Convert PDF to XLSX with Java REST API