The JPG to PDF or in other words the Image to PDF conversion are among the widely used operations and inter file conversion. However, we may have a requirement to convert PDF to Image especially PDF to TIFF because, multiple pages of PDF can be saved as multi frame TIFF image. So in this article, we are going to discuss the details on how to convert PDF to TIFF using Java Cloud SDK.
PDF to TIFF API
As we are looking for PDF file conversion capabilities within the Java application, so Aspose.PDF Cloud SDK for Java is our definite choice. It enables the developers to implement PDF file creation, creation, manipulation and conversion features. No software download or installation is required and all the PDF file processing operations are performed in the cloud. Now in order to use the SDK, we need to add its reference in our project. So please add the following details in pom.xml of maven build type project.
<repositories> <repository> <id>aspose-cloud</id> <name>artifact.aspose-cloud-releases</name> <url>http://artifact.aspose.cloud/repo</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf-cloud</artifactId> <version>21.11.0</version> </dependency> </dependencies>
Once the SDK reference has been added to the project, the next step is to create a free account over Aspose Cloud. So please login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required in subsequent sections.
Convert PDF to TIFF in Java
The PDF to TIFF conversion can be accomplished with fewer code lines. So please follow the instructions given below to accomplish this requirement. Once the PDF to TIFF conversion operation is successful, the resultant file is saved in cloud storage.
- First we need to create a PdfApi object while providing ClientID and Client secret as arguments
- Secondly, load the input PDF file using File instance
- Thirdly, upload the input PDF to cloud storage using uploadFile(…) method
- Now create string variables holding path details for resultant TIFF, and Integer objects defining page number and dimensions for TIFF image
- Finally call the putPageConvertToTiff(…) method requiring input PDF, path of resultant TIFF image, Page number and optional parameters defining resultant file dimensions
PDF to Picture using cURL Commands
As we know that REST APIs can easily be accessed via cURL commands, so in this section, we are going to explore the option of how to convert PDF to TIFF using cURL commands. Now the pre-requisite for this approach is the generation of JWT access token (based on client credentials) while executing the following command.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
Once we have the JWT token, we need to execute the following command to save PDF as TIFF. Please note that in order to save the file locally, we are simply using -o argument and it saves the output on local drive.
curl -v -X GET "https://api.aspose.cloud/v3.0/pdf/input.pdf/pages/1/convert/tiff?width=800&height=1024" \ -H "accept: multipart/form-data" \ -H "authorization: Bearer <JWT Token>" \ -o resultant.tiff
We have explored the options for converting PDF to TIFF using Java code snippet as well as through cURL commands. You may also consider exploring the product Documentation to further explore the other excirting features being offered by Java Cloud API. Furthermore, all our Java Cloud SDKs are published under MIT license, so you may consider downloading the complete source code from GitHub and modfiy it as per your requirements. In case of any issues, you may consider approaching us for a quick resolution via free product support forum.
We highly recommend visiting the following links to learn more about: